Ok – I’ve built a list of businesses that can be sorted by category or city. Some of the businesses are listed in more than one category, so when the list is sorted by city their listing is displayed multiple times.
So how can I set up the loop so that it will only show a listing if it has a unique value for $ad_name in the code below:
[code=php]// SHOW LISTINGS FOR THIS CITY
$query3 = “SELECT * FROM advertisers WHERE city = ‘$city_id2’ ORDER BY name”;
$result3 = mysql_query($query3) or die(‘Query failed: ‘ . mysql_error());
while($row3 = mysql_fetch_array($result3))
{
$ad_id = $row3[‘id’];
$ad_name = $row3[‘name’];
$ad_address = $row3[‘address’];
$ad_city = $row3[‘city’];
$ad_link = $row3[‘link’];
$ad_email = $row3[’email’];
$ad_phone = $row3[‘phone’];
echo ‘<div>’ . $ad_name . ‘</div>’;
That’s a portion of the code that pulls the listings from the database and starts displaying them.
Is it possible to only show unique listings for each city?
Thanks for your help ?