The column (keyword) of a table (market_items) have keywords separating each keyword with a comma. I'm using this query to fetch keywords;
$cid = intval($cid);
$query = $db->query("
SELECT keywords
FROM ".TABLE_PREFIX."market_items
WHERE cid = '{$cid}'
GROUP BY keywords
ORDER BY dateline DESC
");
$cat_tags = '';
while ($t = $db->fetch_array($query))
{
$keywords = trim($t['keywords']);
$keys = explode(",",$keywords);
foreach ($keys AS $key)
{
$cat_tags .= '<span class="small_buttons_class"><a href="market.php?action=tag_items&keywords='.$key.'">'.$key.'</a></span> ';
}
}
It fetches keywords fine but its showing similar keywords like this:
keyword1
keyword2
keyword1
keyword3
keyword4
keyword5
keyword3
"Notice the keyword number above"
How can I remove similar keywords and show it like this? e.g.
keyword1
keyword2
keyword3
keyword4
keyword5
Just to make it clear, in column "keywords" the keywords are stored like this:
keyword2
, keyword4
, keyword3
, keyword1
Please help!