PDA

View Full Version : More search help



Schmoopy
02-19-2009, 12:08 PM
Ok, so I've come up with a way I could possibly do my search bar which would involve selecting all records from the database each time, and then going through those records with preg_match to find a regular pattern and find the record that way.

Of course, that would be very inefficient, so I was hoping there was some way in MySQL you can do: "SELECT * FROM column WHERE column5 = '$search'" At the moment, this would only returnexact matches, which is what I don't want. I want there to be a little flexibility so that if there's a record with the value "Address 50" I want the user to just be able to search 50 and it come up, not have to type the exact value every time. How could I go about doing this? Would it be very complicated?

Master_script_maker
02-19-2009, 08:46 PM
try:
"SELECT * FROM column WHERE column5 LIKE '$search'"

more info here (http://www.google.com/search?hl=en&rlz=1C1CHMB_enUS305US305&q=php+search+tutorial&btnG=Search)

Schmoopy
02-19-2009, 09:25 PM
Ahh, what a useful select clause :)

Thanks.

Master_script_maker
02-19-2009, 10:43 PM
You're Welcome :p