Jump to content

[SOLVED] mysql_query: Select from multiple fields


d-lexy

Recommended Posts

Hi There!

 

I'm writing a very basic search script. I have a form field where I want to accept both first and last names. In my database, the first and last names are in separate fields. I want the query to go through both fields and come up with results. Here is the PHP code so far (only searches first name):

 

$search = $_POST['search'];

$data = mysql_query("SELECT * FROM customers WHERE fname LIKE'%$search%'");

//Display results
while($result = mysql_fetch_array($data))
{
echo $result['fname'];
echo " ";
echo $result['lname'];
echo "<br>";
} 

 

How can i change this around to perform the way I need?

 

Thanks in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.