Jump to content

Archived

This topic is now archived and is closed to further replies.

DarkHavn

trying to search the mysql database but it's not working

Recommended Posts

Hey what i'm trying to do is search the database using the value the user inputs in the search feild that is in PHP.

currently i'm taking the values from this input='text' feild (the user types in keywords) and connecting to the database and running



[quote]
//$keywords contains the value form the search feild
$sql = "SELECT * FROM catalogue WHERE `keywords`='$keywords'";
[/quote]

now in the database, the user can upload up to 200 keywords to a each photo they upload, but for some odd reason, the keywords im testing with match in the database but no results are being returned???

is there a quicker mysql string i can use?

Share this post


Link to post
Share on other sites
Try using LIKE with % wildcards.

Share this post


Link to post
Share on other sites
[quote author=fenway link=topic=106620.msg426569#msg426569 date=1157212260]
Try using LIKE with % wildcards.
[/quote]

How, exactly?

I've been having the same problem.  I have a database full of motorbike parts and I want to be able to search the entire database for a search string such as "clutch" to retrieve all the clutch related parts from my database (ie clutch levers, clutch cables, etc etc)...

I've tried various different variations using LIKE and % and just can't seem to get it to work.  I've even tried using MATCH....AGAINST, but to no avail.  Could you give an example of the code syntax?

Cheers,
Craigypoos


Share this post


Link to post
Share on other sites
Well, field LIKE '%clutch%' is definitely going to work... it's just a question of how efficient this is.

Share this post


Link to post
Share on other sites
Thanks for your reply.

However, I seem to have a MATCH AGAINST clause thing going on now, and it works lovely...

except, some of the words used to search for will be the names of bikes (such as CBR or GSXR) so the 4 letter lower limit kicks in.  It's late now, but I reckon tomorrow I'll try it the LIKE way or write a php IF thingy to choose whether to do the query IN BOOLEAN MODE or not....

Thanks anyway for your (very prompt) help.

Craigypoos


Share this post


Link to post
Share on other sites
Or you can roll-your-own index column.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.