Forum Moderators: open

Message Too Old, No Replies

Search and display article

search for all tags and display title

         

kkonline

6:20 am on Aug 31, 2007 (gmt 0)

10+ Year Member



$pieces = explode(",", $row['tags']); 
for($i = 0; $i<sizeof($pieces); $i++)
{
$tags = mysql_fetch_assoc(mysql_query("SELECT DISTINCT id FROM wow WHERE 0 OR CONCAT(title,content,'') LIKE '%".$pieces[$i]."%' AND id!=$page ORDER BY id DESC"));
echo $pieces[$i];
echo " ";
}

-----part 2-----
for($i = 0; $i<sizeof($pieces); $i++)
{

echo "<br />";
$related = mysql_fetch_assoc(mysql_query("SELECT DISTINCT id,title FROM wow WHERE 0 OR CONCAT(title,content,'') LIKE '%".$pieces[$i]."%' AND id!=$page ORDER BY id DESC"));
if(isset($related)){
echo '<a href="pages.php?catid='.$row['catid'].'&page='.$related['id'].'"><strong>' .$related['title'].'</strong></a>';
}}

In the above code (part 2)it searches all the tags and displays results. However if articles have MORE THAN ONE TAGS IN COMMON it displays the same title again. How to filter that?