Hi, ( I have attached a screen grab of what it looks like )
I am trying to collect tags for tagged photos based on the photo id.
I get duplicates when i do GROUP BY tag_name or DISTINCT tag_name.
- The first query is set up like that because im using pagination.
- The second query gets my tags based on photo id in a loop.
If anyone could help make sense of my queries i would appreciate it
<?php
// Get photo id based on category and dont go beyond the pagination limit.
$sql1 = "SELECT id FROM $tableName WHERE cat_id=".$catid." LIMIT $start, $limit";
$result = mysql_query($sql1);
while ($row1 = mysql_fetch_array($result)) {
// Get tags based on the photo id
$sql2 = "SELECT tag_name FROM photoTagged WHERE file_id=".$row1['id']." GROUP BY tag_name";
$result = mysql_query($sql2) or die(mysql_error());
while ($row2 = mysql_fetch_array($result)) {
$tag = $row2['tag_name'];
?>
<li><a href="#"><?php echo $tag; ?></li>
<?php }} ?>