behrk2 Posted October 17, 2007 Share Posted October 17, 2007 Hey all, So I have a search.html with a form which posts to search.php. I am searching for a last name (l_name), and should it find a result, I want the page to display f_name and l_name. I have somewhat accomplished this, except for the fact that search.php displays the f_name, l_name for every user in the database. Here is my code for search.php: <? //connect to mysql mysql_connect("localhost","root","xxxxxx"); //select database mysql_select_db("hub_info"); $search=$_POST["l_name"]; //get the mysql and store in $result $result = mysql_query("SELECT * FROM ra_info WHERE l_name LIKE '%$search%'"); //grab all the content while($r=mysql_fetch_array($result)) { $f_name=$r["f_name"]; $l_name=$r["l_name"]; //display the row echo "<br>$f_name <br> $l_name <br>"; } ?> Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/73717-solved-displaying-php-search-results/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.