Jump to content

search multiple fields


Recommended Posts

I have a contacts table with name, address, tel number, fax number, etc. How would I setup a search page with only one text box that would return results for any field searched on? ie. user enters a telephone number, results page would show any record that had that same telephone number. user2 enters an address in same text search box, results page shows records with matching address.

 

I guess my real question is how to setup a single entry that will span across multiple fields when it does it's search.

Link to comment
Share on other sites

$result = mysql_query ("select * from TABLE where FIELDNAME like '%$txtsearch%' order by FIELDNAME");
($row = mysql_fetch_array($result))

 

The [*] pulls all fields from that table.

 

If you wished to see only one field replace then [*] with [FIELDNAME]

 

Multi fields [FIELDNAME1, FIELDNAME2]

 

then to pull the field data

 

print ("<TD>");
print $row["FIELDNAME"];
print ("</TD>");

Link to comment
Share on other sites

Close to what I was asking about but not quite.

 

What I meant was...I want to have a single text search box. In this box users will be able to type in any client contact info they want(it will be based on a client contact table). They could type in "3333333333" for a phone number or type in "Billy Bob" or type in "33 Test Rd". From their input the search would look at all fields in the table and return anything that matched. It wouldn't search for a match only on one field. Is this possible? Would it bog down the server on 10 thousand records, 250,000 records?

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.