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
https://forums.phpfreaks.com/topic/24921-php-search-help/
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
https://forums.phpfreaks.com/topic/24921-php-search-help/#findComment-113611
Share on other sites

Archived

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

×
×
  • 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.