I want store some article into database. I use php and mysql.
Whether have a database classification retrieval table?
like:
directory | keyword1 | keyword2 | keyword3 | keyword4|
sport | football | f1 | nba | tennis |
so that:
$query = mysql_query("SELECT * FROM keywordtable WHERE keyword1='$word' OR keyword2='$word' OR keyword3='$word' OR keyword4='$word' ");
if some words in the article match one of the keywords, the article will insert into directory – sport.
Thanks.
I need a table like my example, it should be have many words which can let me reference: if my article appears these words, I can put it into the directory it should in. I know there have more and more words which can be defined into sport.
If I understand what you’re asking, you’d like to have a keyword table against which you can check content. If the content matches any of the keywords, then the content is tagged with the associated directory. If that’s correct then you need 4 tables:
keywords
directories
article_directories
articles, MyISAM
content, text FULLTEXT index
INSERT INTO article_directories(art_id,dir_id)
SELECT DISTINCT a.art_id, k.dir_id
FROM articles a, keywords k
WHERE MATCH (a.content) AGAINST (k.kword)
The above query will identify all possible directories that an article could belong to. This means that an article could belong to both ‘sports’ and ‘entertainment’, for example.