If several instances have same values, list only once
-
Hello there,
I’m having some difficulties with a PHP script using the Simple Fields plugin. I’m still a rookie at PHP so help would be much appreciated.
On my website I’m listing retailers using a set of six fields, where I add the retailer’s name, street adress, zip code, e-mail, city and country. Several retailers are located in the same country, and some in the same city.
Since some retailers are located in the same country, I only want to list each country once, and the same goes for cities. How do I solve this?
My code;
<div id="buy-list"> <ul> <?php $store = simple_fields_get_post_group_values($post->ID, "Store", true, 2); ?> <?php foreach ($store as $store_value) : ?> <li class="buy-country"> <span class="buy-country-span"> <?php echo $store_value["Country"] ?> </span> <ul> <li class="buy-city"> <span> <?php echo $store_value["City"] ?> </span> <ul> <li class='buy-store'> <span> <?php echo $store_value["Retailer"] ?> </span> <ul> <li class='buy-info'> <span> <?php echo $store_value["Retailer address"] ?><br /> <?php echo $store_value["Retailer phone"] ?><br /> <a href="mailto:<?php echo $store_value["Retailer email"] ?>"><?php echo $store_value["Retailer email"] ?></a> </span> </li> </ul> </li> </ul> </li> </ul> </li> <?php endforeach; ?> </ul> </div>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘If several instances have same values, list only once’ is closed to new replies.