title: php loop through sql result
body: <p>I have a table called <code>sales_product</code> with columns</p>
  
  <pre><code>sales_product_id, sales_id, type, class, age
  </code></pre>
  
  <p>I have a query in php saying </p>
  
  <pre><code>$sql = "SELECT * from sales_product WHERE sales_id = " . $_GET['sales_id];
  </code></pre>
  
  <p>Suppose this query returns two rows.</p>
  
  <pre><code>$result = mysql_query($sql);
  </code></pre>
  
  <p>How do I loop through this result and save in an array so that later on I can retrieve data like</p>
  
  <pre><code>echo $sales_product[$i]['sales_product_id'];
  echo $sales_product[$i]['sales_product_id'];
  ........
  </code></pre>