RE: [PHP] fetching words
| From: | Jim Moseby | Date: | Wed, 19 Oct 2005 12:55:46 +0000 |
| Subject: | RE: [PHP] fetching words | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-224323@lists.php.net to get a copy of this message | ||
>
> Hi,
> guys I have two tables, articles and keywords, what I want to do is to
> scan articles and grab every single word
> used in an article to the keyword table
> any idea how to do that
> --
Vague question, and I suspect that there is a much better way to do what you
are trying to do, but since you didn't elaborate, here goes:
<?php
// code here to select article_number, article_text from table
$article_number=$row['article_number'];
$article_words=explode($row['article_text']);
foreach($article_words as $word){
$sql="insert into keywords (article_number, keyword) values
($article_number, '$keyword')";
//code here to toss out common words ('a', 'the', etc), execute
'insert'
query, error check, whatever else
}
?>
JM