Page 1 of 1

how can i make a comprehensive search query?

Posted: Sun Jul 24, 2005 10:07 am
by a_naguib_2000
hi all,
can any body help me?

if have a table in mysql and a code of php that when the user enters the full name, the php code queries the table and returns the results in a web page.

if the user enters for example in the text box the name without putting spaces between the first and the last name it will get no results, cuz it is stored with a space between them..

my question is: how can i make the code get the results of the nonspaced characters and recognize them as spaced characters if the spelling is right as stored in the table???

Posted: Sun Jul 24, 2005 11:53 am
by a_naguib_2000
plz help me, isnt there anybody can do it?

Posted: Sun Jul 24, 2005 12:18 pm
by shiznatix
possibly try using LIKE but that might not work. why would the person enter it without spaces? why not try doing a form with 2 fields, one with first name then 1 with last name then trim() the 2 and join them into 1 variable with a space between them

Posted: Sun Jul 24, 2005 7:45 pm
by timvw
If you can make a distinction between firstname and lastname... and only have a name attribute in your database... your database isn't normalized as it should be...

As mentionned already, offer for each column an input field.. Use all those that are !empty to build a WHERE clause and off you go... (Might want to use LIKE instead of = when people enter % in the inputfield)