title: Fetching rows from database via a prepared statement
body: <p>I initially created the below query to return some results from my database.</p>
  
  <pre><code>$result = mysqli_query($con, "SELECT bookingId, locationName 
                                FROM bookings 
                                WHERE username = '$one'");
  $output = array();
  while($row = mysqli_fetch_assoc($result)) {
    $output[]=$row;
  }
  print(json_encode($output));
  </code></pre>
  
  <p>However, I now want to use prepared statements and have tried the below. But It always returns <code>[]</code>. Is this the correct way to return rows via a prepared statement.</p>
  
  <pre><code>$stmt = $con-&gt;prepare('SELECT bookingId,locationName
  FROM bookings
  WHERE username= ?');
  $stmt-&gt;bind_param('s', $one);
  $stmt-&gt;execute();
  $stmt-&gt;bind_result($id, $loc);
  $output = array();
  while($row = $stmt-&gt;fetch()){
  $output[] = $row;
  }
  $stmt-&gt;close();
  
  print(json_encode($output));
  </code></pre>