title: extract values from a returned sql query
body: <p>I am working in PHP.
  I have a database that i pull data from.
  I have at the moment the data output to a table.</p>
  
  <p>My wish is to take this table and seperate the data to pass to seperate variables, do i some how pass to an array?</p>
  
  <p>eg
  original    </p>
  
  <pre><code>Name          hours
  Bob             4
  Harry           6
  Bob             2
  Harry           5
  Dave            1
  Bob             2
  </code></pre>
  
  <p>Returned and in table</p>
  
  <pre><code>Bob             3
  Harry           2
  Dave            1
  </code></pre>
  
  <p>i'd like to take each value seperately as i wish
  and also in row order so i then have variable</p>
  
  <p><code>
   Bob   = 3,
   Harry = 2,
   Dave  = 1</code></p>
  
  <p>and also take the values of 3,2,1</p>
  
  <p>this will then be output and variables used to create a pie chart</p>
  
  <p>Here is my sql query</p>
  
  <pre><code>    $dbHandle = new PDO("mysql:host=$host;dbname=$dbName",$user,$pass);
      $query ="SELECT platform, count(*) FROM review GROUP BY platform";
      $sqlQuery = $query; // put your students table name
      echo $sqlQuery;  //helpful for debugging to see what SQL query has been created
      $statement = $dbHandle-&gt;prepare($sqlQuery); // prepare PDO statement
      $statement-&gt;execute();   // execute the PDO statement
      echo "&lt;table border='1'&gt;";
      while ($row = $statement-&gt;fetch()) {
      echo "&lt;tr&gt;&lt;td&gt;" . $row[0] ."&lt;/td&gt;&lt;td&gt;". $row[1];}
      echo "&lt;/table&gt;";
      $dbHandle = null;
  </code></pre>