Jump to content


PHP Search Help

  • Please log in to reply
2 replies to this topic

#1 Pythondesigns

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 24 October 2006 - 11:29 AM


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(id, tag);

files(id, 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.


#2 jvrothjr

  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 24 October 2006 - 12:46 PM

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?
("select * from files where title like '%$Keywords%' or desc like '%$Keywords%' or url like '%$Keywords%'")

If you understand everything you know nothing!


#3 Pythondesigns

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 24 October 2006 - 02:30 PM

Its ok Ive figured it out.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users