Jump to content

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


DarkHavn

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?
Link to comment
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


Link to comment
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


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.