View Single Post
  #1 (permalink)  
Old 12-07-03, 09:49 PM
bobdole bobdole is offline
New Member
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
searching from a form where some fields are not required

Ok, I have a form with things like last name, first name, phone number, etc.

I need for my php script to search through my mysql database, but only if the user entered something into the given field. So if they only entered a first name it would only find the entries in the database with that first name. None of the fields are required.

How can I either search for all the entries with a first name, and then search those results for all the entries with the specified last name and so on, or just do one search where i check before hand to see if there are entries in each field and if there are not, simply put a wildcard in that field in the query.

Basically I would like to "build" the query as I check each field to see if anything is there. Any Ideas?
Reply With Quote