Page is a not externally linkable
Davidkarate - 5:46 pm on Jun 11, 2012 (gmt 0)
I have four table: classifieds, state, city and img. I want to display all images which belong to a unique id(user).
For ex: A user from Minneapolis(city) Minnesota(state) posts an ad about selling a car that has 5 pictures.
My tables structure:
classifieds:
id, title, description, state_id, city_id
state:
id, statename
city:
id
city
img:
id
classified_id
I got everything working with this query, except the result is repeating user information for every image.
<?php
$query = mysql_query("SELECT * FROM classifieds
LEFT JOIN img ON img.classified_id = classifieds.id
LEFT JOIN state ON classifieds.state_id = state.id
LEFT JOIN city ON classifieds.city_id = city.id WHERE id = '".$id."' AND
authorized = '1'
");
while($row = mysql_fetch_array($query, MYSQL_ASSOC))
{
?>
<div align="center"><a href=' <?php echo $row['image_path']; ?>' rel='lightbox'
title='<?php echo $row['title']; ?>' style='text-decoration:none;'> <img
src='<?php echo $row['image_path']; ?>' width='150' border='0' />
</a>
</div>
<div class="show_location" style="width:225px; hight:10px; padding-top:20px;">
<span class='style55'><?php echo $lang['D_STATE']; ?> <span style="color:#06F">
<?php echo $row['statename']; ?></span> </div>
<div style="width:225px; hight:10px; padding-top:20px;"> <?php echo
$lang['D_CITY']; ?><span style="color:#06F"> <?php echo $row['city']; ?></span>
</span> </div>
<?php
}
?>
Thanks in advance