title: Using PHP to Display & Sort Data From MySQL
body: <p>I have a list of variables that I need echoed on a page - based on their order in the database.</p>
  
  <p>Here's the code I have right now:</p>
  
  <pre><code>$1 = 'Download - First Product';
  $2 = 'Download - Second Product';
  $3 = 'Download - Third Product';
  
  $downloads = mysql_query('SELECT id FROM tbldownloads ORDER BY downloads DESC');
  </code></pre>
  
  <p>In the <code>tbldownloads</code> table, there's a column named <code>downloads</code> which has the number of downloads each product has.  The variables above correspond with each <code>id</code> for each product in the database.</p>
  
  <p>What I want to do is list my products based on the amount of downloads they've had.  They should be ordered from the most downloaded to the least downloaded products.</p>
  
  <p>Am I doing this the right way or is there a better way to do that?  What I'm getting stuck on is how to check the amount of downloads and then sort them to be displayed...</p>