how can i make a comprehensive search query?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
a_naguib_2000
Forum Newbie
Posts: 5
Joined: Fri Jul 22, 2005 7:33 am

how can i make a comprehensive search query?

Post 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???
a_naguib_2000
Forum Newbie
Posts: 5
Joined: Fri Jul 22, 2005 7:33 am

Post by a_naguib_2000 »

plz help me, isnt there anybody can do it?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
Post Reply