I'm trying to create "related articles" for our news, based on tags (single word tags). If a story is tagged with 3 tags, I'd like to be able to pull up the most recent entries for each tag, order them by date, and display only the most recent 5.
Here's what I'm trying, that obviously doesn't work, because it overwrites the array variable $pullRelated with the last tag it goes through. Since i got stuck there, I wasn't sure how to go about sorting all the entries by date and then only displaying the most recent 5. Any help is appreciated. Thanks!
foreach ($tags as $t) {
$pullRelated = mysql_query("SELECT * FROM posts WHERE MATCH(tags) AGAINST ('$t') AND status >= 2 AND newsID != $newsID ORDER by postDate DESC LIMIT 5");
}
while($related = mysql_fetch_array($pullRelated)) {
echo $related['postTitle']." ".date("M j, Y",$related['postDate'])."<BR>";
}