leeroy1 Posted February 9, 2004 Share Posted February 9, 2004 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. Quote Link to comment https://forums.phpfreaks.com/topic/1658-search-multiple-fields/ Share on other sites More sharing options...
jvrothjr Posted February 9, 2004 Share Posted February 9, 2004 $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>"); Quote Link to comment https://forums.phpfreaks.com/topic/1658-search-multiple-fields/#findComment-5449 Share on other sites More sharing options...
leeroy1 Posted February 11, 2004 Author Share Posted February 11, 2004 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? Quote Link to comment https://forums.phpfreaks.com/topic/1658-search-multiple-fields/#findComment-5460 Share on other sites More sharing options...
leeroy1 Posted February 12, 2004 Author Share Posted February 12, 2004 I got it going. Just created a sql statement for the record set results to find %fieldname% for each field name and pointed to the posted text entry. Quote Link to comment https://forums.phpfreaks.com/topic/1658-search-multiple-fields/#findComment-5462 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.