title: How do I loop through MySQL results easily?
body: <p>I've been requesting MySQL results and looping through them like this:</p>
  
  <pre><code>$query = "SELECT * FROM $table";
  $result = mysql_query($query);
  for($i = 0; $i &lt; mysql_num_rows($result); $i++){
      echo mysql_result($result, $i, $row);
      //do something else;
  }
  </code></pre>
  
  <p>you can probably see what happens. What if a row has been deleted? What if the first item is gone? In that case, there could be 30 items in the list, but the last items index is at position 50. How do I fix this or what other systems can I use?</p>