title: mysql_fetch_array and while loop in php
body: <p>I'm trying to get data from DB and print it on the page. I use next select:</p>
  
  <pre><code>$tableIndex=mysql_query('SELECT table_index FROM table_names');
  </code></pre>
  
  <p>When I use a <code>while</code> loop to print, it's ok.
  Code:</p>
  
  <pre><code>while($row = mysql_fetch_array($tableIndex) ){
          echo $row[0].'&lt;br&gt;';}
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>1st
  
  2nd
  
  3rd
  </code></pre>
  
  <p>But without <code>while</code> loop, it gives me just first element of array.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$row = mysql_fetch_array($tableIndex);
      echo $row[0].'&lt;br&gt;';
      echo $row[1].'&lt;br&gt;';
      echo $row[2].'&lt;br&gt;';
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>1st
  
  _
  
  _
  </code></pre>
  
  <p>(where "_" is blank space)</p>
  
  <p>Can someone expalin why it works so strangely?</p>