title: Why can't I fetch all rows from database instead of just a single entry?
body: <p>I have tried to get all rows from a specific table 'comments' but I get no response. I can pull a specific row based on 'id' but not all rows. I am trying to fetch all entries and return them as a json response. This code works for other tables but not for this specific table and I have no idea why. Here's what I have tried:</p>
  
  <p>This works for retrieving a specific row by 'id':</p>
  
  <pre><code>&lt;?php
  header('Content-Type: application/json');
  include_once("config.php");
  
  $query=mysqli_query($con,"SELECT * FROM comments WHERE sid=".$_GET['sid']);
  
  $array;
  while($result=mysqli_fetch_assoc($query)){
  
  $array[]=$result;
  }
  
  header('Content-Type: application/json');
  echo json_encode($array);
  ?&gt;
  </code></pre>
  
  <p>But if I try this for all rows, I get a blank response:</p>
  
  <pre><code>    &lt;?php
  header('Content-Type: application/json');
  include_once("config.php");
  
  $query=mysqli_query($con,"SELECT * FROM comments");
  
  $array;
  while($result=mysqli_fetch_assoc($query)){
  
  $array[]=$result;
  }
  
  header('Content-Type: application/json');
  echo json_encode($array);
  ?&gt;
  </code></pre>