<分区>
这是我的表tracks
:
+---+--------------------+
| id| tag|
+---+--------------------+
| 1 | dance,|
| 2 | dance,tecno,|
| 3 | dance,hihop,|
| 4 | rap,|
| 5 | country,|
| . | ...|
+---+--------------------+
我试过了($value
是我的查询):
$tags = $this->db->query(sprintf("SELECT `tag`, `id` FROM `tracks` WHERE `tag` LIKE '%s' GROUP BY `tag` DESC LIMIT %s, %s", '%'.$this->db->real_escape_string($value).'%', $this->db->real_escape_string($start), $per_page));
while($row = $tags->fetch_assoc()) {
$rows[] = $row;
}
$tags = explode(',', $row['tag']);
$rows = array_unique(array_map('strtolower', $tags));
foreach($rows as $row) {
if(stripos($row, $value) !== false) {
$tag_output .= '<div class="hashtag-inner">
'.$row.'
</div>';
}
}
从这个例子。预期的输出是:dance, tecno, hiphop, rap, country
带有所有唯一标签而不是我有标签 dance
的多个输出。
我的输出有什么问题?