title: this foreach loop returns double the results
body: <p>i am trying to run a script to get the member ids of a particular group.
  when i use the foreach loop it returns each result twice and sometimes will miss the last result in the database.</p>
  
  <p>here is my code:</p>
  
  <pre><code>    &lt;?php
      include_once("scripts/checkuserlog.php");
      $squadid = "";
      if (isset($_GET['pid'])){ $squadid = $_GET['pid'];};
  
      $sqlName = "SELECT mem_id FROM team_members WHERE team_id='$squadid' AND is_member='1'" or die ("Sorry we had a mysql error!");
      $queryName = mysqli_query($db_conx, $sqlName);
      while($array = mysqli_fetch_array($queryName)){
          foreach($array as $value){
              echo "$value&lt;br/&gt;";
          } 
      }
      ?&gt;
  
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;title&gt;Untitled Document&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>the result this throws up would look something like:</p>
  
  <pre><code>3
  3
  2
  2
  1
  1
  4
  4
  5
  5
  </code></pre>
  
  <p>obviously there should only be one of each number as each member can only join each group once.</p>
  
  <p>i have never really used foreach loops before no am not 100% sure on their working, i have done a bit of research on the syntax but cant work out where i am going wrong. i can only assume i am calling something twice but not sure where.</p>
  
  <p>if anyone knows of a better method to achieve what i need other than a foreach loop i am all ears</p>
  
  <p>thanks</p>