Jump to content

Keyword Search


benwhitmore

Recommended Posts

Hi Peeps,

I have one table with three fields, id, name, description.

I want to perform a keyword search on the table in the description field and then return the id of each record that has a keyword match.

I dont think this will work:-

[code]

"SELECT id FROM table WHERE description LIKE '$keyword'"
[/code]

Any ideas to point me in the right direction?

ps. I dont need to know how to display the results, its just the initial search i am stuck with

Thanks in advance!
Link to comment
Share on other sites

You'll have to setup an if statement that verifies that something is in both, because you'll only want to put the ones with values in them in the WHERE clause.

pseudo-code:

if something in namebox and descriptionbox
$query .= WHERE name LIKE namebox OR description LIKE descriptionbox
elseif something in namebox and nothing in descriptionbox
$query .= WHERE name LIKE namebox
etc.

You may want to give them the option to search with an OR or an AND if they specify both.
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.