Re: PHP Search DB Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oliver Kennedy wrote:

> 
> 
> Hello Everyone
>  
> Apologies if I have not done this in the correct way, this is the first
> time I have turned to your for help so I am unaware if I have to submit
> this according to a certain protocol, if that is the case then please let
> me know and I will go through the proper channels. My problem is this.
>  
> I have a very simple database consisting of 1 table, I want users here to
> be able to use a search function to query the database in order to return
> the information on a client by a specific ID number if it is in the
> database. My search form is this
>  
> <body>
> <div id="container" >
> <form action='datasearch.php' method='POST'>
> <div id ="options">
> <p><label>Search by Client ID<br /><input type="text" name="searchx"
> /></label></p> <p><input type="submit" value="Search" /></p>
> </div>
> </div>
> </form>
> </body>
> </html>
>  
> and my process form is this
>  
> <?php
> $term = $_REQUEST['searchx'];
> mysql_connect("localhost", "root", "*********") or die (mysql_error());
> mysql_select_db("moneyl") or die(mysql_error());
> $result = mysql_query("SELECT * FROM clients WHERE clientid = '$term'")
> or die(mysql_error());
> echo"<table border='1'>";
> echo "<tr><th>Client ID</th> <th>Feeearner</th> <th>First Name</th>
> <th>Middle Name</th>
> <th>Last Name</th>
> <th>House/Flat Number</th>
> <th>Address</th>
> <th>Postcode</th>
> <th>Gender</th>
> <th>Date of Birth</th>
> <th>Landline</th>";
> while($row = mysql_fetch_array( $result ))
> {
> echo "<tr><td>";
> echo$row['clientid'];
> echo"</td><td>";
> echo$row['feeearner'];
> echo"</td><td>";
> echo$row['firstname'];
> echo"</td><td>";
> echo$row['middlename'];
> echo"</td><td>";
> echo$row['lastname'];
> echo"</td><td>";
> echo$row['hfnumber'];
> echo"</td><td>";
> echo$row['address'];
> echo"</td><td>";
> echo$row['postcode'];
> echo"</td><td>";
> echo$row['gender'];
> echo"</td><td>";
> echo$row['dob'];
> echo"</td><td>";
> echo$row['landline'];
> echo"</td></tr>";
> }
> echo"</table>";
> ?>
>  
> I know the form is connecting an retrieving okay because if I change the
> WHERE client id = '' to a specific number of a client ID in the database
> then it comes back with that information, so essentially it is not pulling
> through the numbers entered into the search box the value for which I have
> used REQUEST for and specified it with the value $term.
>  
> I am a beginner at this and am trying to do something to impress the
> powers-that-be at work, this is now the last stumbling block. Any help
> would be appreciated.
>  
> Regards
>  
> Oliver

Try

$query = "SELECT * FROM clients WHERE clientid = '$term'";
echo $query . '<br />';
$result = mysql_query($query);

And see what is actually in the query.

Cheers
-- 
David Robley

Reality is nothing but a collective hunch.
Today is Pungenday, the 56th day of The Aftermath in the YOLD 3176. 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux