title: Extraction data from MySQL table using PHP
body: <p>i'm trying to extract data from mysql. I have some query looking like this <code>SELECT q1, COUNT(*) FROM results GROUP BY q1</code> and as result I'm expecting something like this:</p>
  
  <pre><code>q1  COUNT(*)
  0   7
  1   1
  2   4
  3   1
  </code></pre>
  
  <p>It works in phpMyAdmin workflow, but if I try to repeat this query from my pagename.php file I'm failed.</p>
  
  <pre><code>$q1_ans = mysqli_query($link, "SELECT q1, COUNT(*) FROM results GROUP BY q1");
  $q1_arr = mysqli_fetch_assoc($q1_ans);
  foreach($q1_arr as $key =&gt; $value) {
          echo "&lt;br&gt;$key is at $value";
        }
  </code></pre>
  
  <p>And as result I have</p>
  
  <p>q1 is at 0
  COUNT(*)  is at 7</p>
  
  <p>How can I get array looking like this??</p>
  
  <pre><code>0 is at 7
  1 is at 1
  2 is at 4
  3 is at 1
  </code></pre>