title: Database values are repeating in for loop
body: <p>I am selecting authorname from database depending on array condition. But when i return the code i saw my condition is repeating twice.</p>
  
  <p>my code is here</p>
  
  <pre><code>$alpha=array('A','B','C','D','E','F');
      $countarray=sizeof($alpha);
      $alert.=$countarray;
      for ($a=0;$a&lt;=$countarray;$a++)
      {
          $selectlist="select * from quotationauthor where Author_name Like'$alpha[$a]%'";
          $result=mysqli_query($con,$selectlist)
                  or die(mysqli_error($con));
          $countauthor=countlist($result);
          if($countauthor &lt; 1)
          {
  
          }
          else
          {
              $alert.="&lt;h1&gt;$alpha[$a]$countauthor&lt;/h1&gt;&lt;br/&gt;";
              while($row=mysqli_fetch_array($result))
              {
                  $alert.=$row[Author_name]."&lt;br/&gt;";
              }
          }
      }
      return $alert;
  </code></pre>
  
  <p>Suppose i got A at first condition than it will search for the authorname in my database which is starting from A. I am getting the right output but my problem is database values are written twice</p>
  
  <pre><code>6
  A
  
  
  Albert Einstein
  Abraham Lincoln
  Abdul Kalam
  Adolf Hitler
  
  Albert Einstein
  Abraham Lincoln
  Abdul Kalam
  Adolf Hitler
  </code></pre>
  
  <p>As you can see database values are written twice. I have checked my database and found that there is only 4 rows.</p>