Jump to content

[SOLVED] Displaying PHP Search Results


behrk2

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.