I want to fetch all tags from my Database and make a "Tags" page (containing all of the tags on the site) with count. something like: "Music (32) Music video (2) guitar (4)" etc..
problem is when I fetch the tags I get a list like this: "music, guitar, videos" "guitar lesson, how to play guitar, jimi hendrix" etc. which means I can only count "music, guitar, videos" as a tag and "guitar lesson, how to play guitar, jimi hendrix" as a tag and not "music" as a tag, "guitar" as a tag etc. separately...
I believe I need to use the "explode" function to split them up, then "array_unique" to remove duplicates and then "count" to count them. Am I right?
this is the code I got:
Code: Select all
<?
$result = mysql_query("SELECT keywords FROM content ORDER BY keywords ASC")
or die(mysql_error());
$arr_keywords = array();
while($row = mysql_fetch_array($result))
$arr_keywords[$row['keywords']] = $row['keywords'];
$clean = array_unique($arr_keywords);
$count = count($clean);
$json = json_encode($clean);
echo $json[$count] ;
?>All I get is the page full of thousands of tags and they are not separated nor counted
Thanks in advance for the help!