Hi,
I have searched high and low and cant find a similar issue to what i have.
I am a beginner so please forgive my clunky query structure.
I am trying to: ( have attached screen grab below )
Query the photos table to get the id based on category id and also start,limit because of pagination.
Query the photos tagged table based on the photo id i just got from the first query.
But my problem is that i cant group the tags, some photos have the same tag name. And the output just shows all the tags for each photo. I want restaurant to show only once etc...
<?php
// Get the file ideez and dont go beyond pagination start,limit eg:30,10
$queryFile = "SELECT id FROM $tableName WHERE cat_id=".$fileID." LIMIT $start, $limit";
$resultFile = mysql_query($queryFile);
while ($rowFile = mysql_fetch_array($resultFile)) {
// Get the tag names based on the file ideez retrived from the above query
$queryTagged = "SELECT tag_name FROM photoTagged WHERE file_id=".$rowFile['id']." GROUP BY tag_name";
$resultTagged = mysql_query($queryTagged) or die(mysql_error());
while ($rowTagged = mysql_fetch_array($resultTagged)) {
$tagged = $rowTagged['tag_name'];
?>
<li><a href="#"><?php echo $tagged; ?></li>
<?php }} ?>
the above query is producing:
bar,cappucino,coffee,coffee machine,restaurant,bar,cappucino,coffee,coffee machine,restaurant,bar,coffee,restaurant,bar,coffee,coffee machine
restaurant,bar,cappucino,coffee,restaurant
what i need to show is: bar,cappucino,coffee,coffee machine,restaurant
If anyone could help i would greatly appreciate it.
Thank you in advance.
John