我有一个带有以下内容的数据库
----id---|-----name-----|-----owner----|----tags---------------|
----1----|-----123------|------jc------|--van outside door-----|
----2----|-----124------|------dw------|----van daz------------|
----3----|-----125------|------jc------|--daz outside flower----|
我想要做的是回显标签列中所有单词的列表,而不重复相同的单词。
到目前为止,我已经设法回应
van outside doorvan dazdaz outside flower
注意重复的单词和行之间没有空格。
我也希望结果是 url 链接?t=$tag
这是为了对照片进行分类。我应该将标签列中的分隔符更改,
为daz,indoor,flower
.
这是我的代码
$sql = "SELECT * FROM photos";
$filterresult = mysql_query($sql);
while($row = mysql_fetch_array($filterresult))
{
$id = $row['id-name'];
$name = $row['name'];
$owner = $row['owner'];
$tags = $row['tags'];
$filterdir = "photos/$owner/index_files/vlb_thumbnails1/";
$filterdir2 = "photos/$owner/index_files/vlb_images1/";
echo "<a href=\"photoview102.php?t=$tags\">$tags</a>";
}
好的,这是新代码(到目前为止感谢您的帮助)
$tags = array();
$sql = "SELECT * FROM photos";
$filterresult = mysql_query($sql);
while($row = mysql_fetch_array($filterresult))
{
$id = $row['id-name'];
$name = $row['name'];
$owner = $row['owner'];
$tags = array_merge($tags, explode(' ', $tags));
$filterdir = "photos/$owner/index_files/vlb_thumbnails1/";
$filterdir2 = "photos/$owner/index_files/vlb_images1/";
}
$tags = array_unique($tags);
foreach ($tags as $tag) {
echo "<a href=\"photoviewer102.php?t=$tag\">$tag</a>";
}