Page 1 of 1
wildcard search
Posted: Fri Dec 08, 2006 10:05 pm
by kippy
I am looking for the best way to use the wildcard % witha php variable...I am trying to create a site searc feature and I think the wildcard is the answer. I have tried just about every combination in the query and have been unable to get it to work...any help would be appreciated...thanks!
Posted: Fri Dec 08, 2006 10:43 pm
by feyd
What, exactly, have you tried?
Posted: Fri Dec 08, 2006 11:09 pm
by kippy
First off...you are always on! I have visited many different times and you are always responding(quick)....for that I thank you!
as for te wildcard I am setting up a select * from TABLE where var like '$searchVar%'...., but of course this has not worked...I have tried to search for an example of code doing a similar search with a variable, but no luck!
Posted: Fri Dec 08, 2006 11:13 pm
by feyd
That's the general idea behind most of the searches that use the LIKE keyword. Many searches will use FULL TEXT indexes however.
You can have multiple percentage symbols in the LIKE statements.
Posted: Fri Dec 08, 2006 11:14 pm
by kippy
the problem is the search is pulling nothing...so I am concerned that the syntax is incorrect
Posted: Fri Dec 08, 2006 11:20 pm
by kippy
scratch that...got it too work...thanks for the help! Being a newbie...I am sure I will be back...!
Posted: Fri Dec 08, 2006 11:21 pm
by feyd
Have you echoed the query to determine if it appears correct? Have you run this resulting query directly against the database with a known working interface?