title: Create unique single <div> element  for all MySQL php results with particular value
body: <p>Here is my problem. I am returning results from a mysql database and using a for loop to echo the results. Though its getting a little complicated because I am using some table data to nest inside other results. This code returns "Pablo Picasso" inside a div called "Spain", fine, but if there is "El Greco" in Spain too, then I get two "Spain" divs, rather than just the one.</p>
  
  <p>So: I'd like to only return a result once for each unique value in a table column, rather than for every one. </p>
  
  <pre><code>$results = array();
  while ($row = mysql_fetch_assoc($result)) {
  $results[] = $row;
  }
  
  foreach ($results as $row)
      {
      echo "&lt;div class=\"".$row['country']."\"&gt;".$row['country'];
      echo "&lt;div class=\"Box\"&gt;";
      $tempCountry = $row['country'];
  
      foreach ($results as $row)
      {
      if ($row['country']== $tempCountry) echo "&lt;div&gt;artists name&lt;/div&gt;";
      }
  
      echo "&lt;/div&gt;";echo "&lt;/div&gt;";
  }
  </code></pre>
  
  <p>I'm wondering if it is the construction of the nested loop, or something else, I don't know!!! Please help</p>