it's simple but yet complicated...php and mysql search..
Expand Post »
I fond some tutorial that can search one field of the table in a database,. But I would like to search the whole table.. In my table I have people's name by first name, last name, phone number etc... how can I display the whole thing as a result? For example if someone was to type only John... the results would show, John's first name, last name, phone number... etc....
Last edited by desiguru; Aug 3rd, 2006 at 7:31 pm.
Re: it's simple but yet complicated...php and mysql search..
You'll need to use a bit of conditional testing to build the appropriate sql string based on the submitted search terms. A simplified example shown below assumes the user can chooseto search on either firstname, lastname or both.
Re: it's simple but yet complicated...php and mysql search..
What are the search parameters you want to handle? Does the single search box mean that users will only search on firstname, or possibly firstname and lastname, or possibly lastname only? Or all three?
Re: it's simple but yet complicated...php and mysql search..
btw, you should not play to hard with Like '%%', especially if you will have pager there (limit) as well as ability to sort by some fields (order by).
if you need - i can a short storty about doing that on big "for gamers" site.
briefly, try just to find some good book on database design, and read what can be done, what should be done and how
Re: it's simple but yet complicated...php and mysql search..
Quote originally posted by EFEXConsulting ...
btw, you should not play to hard with Like '%%', especially if you will have pager there (limit) as well as ability to sort by some fields (order by).
if you need - i can a short storty about doing that on big "for gamers" site.
briefly, try just to find some good book on database design, and read what can be done, what should be done and how
best regards
I will try my best and if I have further questions, I will post them here. Thanks for your help
Re: it's simple but yet complicated...php and mysql search..
In mysql, you can use "FULL TEXT SEARCH" option. For this you have to add index on all of three fields First name, Last name and Phone.
After that you will use the query
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.