title: PHP/MySQL: fetch one result
body: <p>This is my database:</p>
  
  <p><img src="https://i.stack.imgur.com/Kb7Rv.png" alt="database"></p>
  
  <p>This is the query:</p>
  
  <blockquote>
    <p>SELECT * FROM users</p>
  </blockquote>
  
  <p>Now when I do this:</p>
  
  <pre><code>$query = $connection-&gt;query($_GET['query']); // SELECT * FROM users
  print_r($query-&gt;fetch_assoc());
  </code></pre>
  
  <p>I get this as output:</p>
  
  <blockquote>
    <p>Array (
        [id] => 3
        [username] => karel )</p>
  </blockquote>
  
  <p>Why does it not output id 4 and username ccscs?</p>
  
  <p>When I a while loop:</p>
  
  <p><img src="https://i.stack.imgur.com/MibPA.png" alt="whileloop"></p>
  
  <pre><code>while($row = $query-&gt;fetch_assoc()){
      print_r($row);
  }
  </code></pre>