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! Link to comment https://forums.phpfreaks.com/topic/73717-solved-displaying-php-search-results/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.