Forum Moderators: open

Message Too Old, No Replies

Related article search (using tags)

how to write the query

         

kkonline

3:35 am on Aug 30, 2007 (gmt 0)

10+ Year Member



I am working on an article manager. For every article i have a tag defined (similar to flickr).

For example when i access mysite.com/pages?page=1 then suppose it's tags are life,confidence,success,honesty

Now below the actual article content i want to show all the articles avaiable in the database WHICH HAVE ANY ONE OF THE TAGS OR MORE TAGS ASSOCIATED WITH IT. That means any other article (in same table) should be displayed which have the same tag associated witrh them

Table name: articles
Database name: mysqldb

So how do i write the search query?

kkonline

8:33 am on Aug 30, 2007 (gmt 0)

10+ Year Member



I am writing something like

SELECT DISTINCT id FROM wow WHERE 0 OR CONCAT(title,content,views,'') LIKE '%$row['tags']%' ORDER BY id DESC;

But the tags which are stored in db are separated by commas example life,success,destiny (can be any number of tags separated by comma)

and if i write $row['tags'] it will take it as a complete string and try to match which will give the article itself as a result of search query.

I want to search wow table if any of the articles (other than the current) have tags keyword "life" , "success" , "destiny" all three or any of the one then only those results should be displayed