Search and display article

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Search and display article

Post 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?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

"... AND id != (First ID) ..."
?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

oops
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply