Jump to content

PHP Search Help


Pythondesigns

Recommended Posts

Hello,


I am trying to create a search feature in PHP where my users can type in keywords and it will return the results.

But it will be using two tables and use a sort of tag system. Here are my tables


tags([u]id[/u], tag);

files([u]id[/u], title, desc, url, tagIDs*);


Ok, if for example someone typed into the search form the keywords "apple ipod". I want it to search the tags table for first "apple" and then "ipod". If those tags arent already present in the tags table insert them. If they are present then get their ID's.

Then search through the files table for all rows which has got the tag's ID in the tagIDs field. Then display the result and if possible order them by relevance.


So basically this is a search script which keeps track and records the different keywords used and assigns each record in the files table a number of tags. The tagIDs field in the files table can contain more than one tag ID.


Could any one show me how I could do this.

Thanks
Link to comment
Share on other sites

First question is why have a TAG table why not just search the file table for the data. This search Tag if not there add will be more time then just searching the file table for keyword?

Second what field(s) are you searching in the files table with the keyword?

May thought on this would be you would need to search files every time anyway to catch the new records so why do a search for tagIDs and keywords?
[code=php:0]
("select * from files where title like '%$Keywords%' or desc like '%$Keywords%' or url like '%$Keywords%'")
[/code]
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.