我想从我的数据库中检索一些标签,它们的形式是:
topic_id       tags
   1        `tag1,tag2,tag3`
   2        `tag1,tag4,tag5`
   3        `tag2,tag4,tag5`
   4        `tag6,tag7,tag2`
我想要这样的东西:
tag1 tag2 tag3 tag4 tag5 tag6 tag7
即所有唯一标签
这样我就可以将每个标签包装在一个链接中,以便对具有此类特定标签的新闻文章进行分组。
到目前为止,我编写的以下查询不起作用:
$tags = mysql_query("SELECT tags, topic_id
                       FROM forum_topics
                       WHERE topic_id > 0")  or die (mysql_error());
                    while($tag = mysql_fetch_assoc($tags)){   
                    $split_tags  = "$tag";
                    $pieces = explode(",", $split_tags);
                    echo $pieces ;
当我这样做的时候  print_r($pieces);
我有Array ( [0] => Array ) Array ( [0] => Array ) Array ( [0] => Array ) Array ( [0] => Array )
这不是我想要的。
因为现在我的表结构看起来像这样topic_id , topic_head, topic_body, topic_tag, topic_date, topic_owner.. 我怎样才能进一步使 topic_tag 正常。