Page 1 of 1

Search and display article

Posted: Fri Aug 31, 2007 1:21 am
by kkonline

Code: Select all

$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?

Posted: Fri Aug 31, 2007 9:46 am
by Zoxive

Code: Select all

"... AND id != (First ID) ..."
?

Posted: Fri Aug 31, 2007 9:57 am
by VladSun
oops