title: SELECT * from SQL table using prepared statement
body: <p>I'm using a prepared statement to <code>SELECT *</code> from a MySQL table and I'm not sure how to use <code>while($row = mysqli_fetch_array($stmt))</code> to loop through and select items from the result array. This is my code, what am I doing wrong?</p>
  
  <pre><code>    $link = mysqli_connect($host, $username, $password, $db);
      $query = "SELECT * from `wp_posts` WHERE ID=? ";
      //$result = mysqli_query($link, $query);
      $stmt = mysqli_prepare($link, $query);
      if($stmt){
          mysqli_stmt_bind_param($stmt, "i", $pid);
          mysqli_stmt_bind_result($stmt, $dbpid);
          mysqli_stmt_execute($stmt);
          mysqli_stmt_fetch($stmt);
      }
      while($row = mysqli_fetch_array($stmt)){
          ?&gt;
      &lt;h2 align="center"&gt; &lt;?php echo $row['post_title']; ?&gt; &lt;/h2&gt;&lt;br&gt;
      &lt;div class="paracenter"&gt;
  
          &lt;p id="cont"&gt;&lt;?php echo $row['post_content']; ?&gt;&lt;/p&gt;
          &lt;hr color="black" width="10%"&gt;
  
      &lt;/div&gt;
      &lt;?php } ?&gt;
  </code></pre>