title: Prepared Statements - Number of Rows
body: <p>I'm just trying to figure out how to determine the number of rows and then make that number display in the HTML.</p>
  <p>My prepared statement looks like this:</p>
  <pre><code>if($stmt = $mysqli -&gt; prepare(&quot;SELECT field1, field2, field3 FROM table WHERE id= ?ORDER BY id ASC&quot;)) 
      {
      /* Bind parameters, s - string, b - blob, i - int, etc */
      $stmt -&gt; bind_param(&quot;i&quot;, $id);
      $stmt -&gt; execute();
      
      /* Bind results */
      $stmt -&gt; bind_result($testfield1, $testfield2, $testfield3);
      
      /* Fetch the value */
      $stmt -&gt; fetch();
  
      /* Close statement */
      $stmt -&gt; close();
     }
  </code></pre>
  <p>I understand that I'm supposed to first save the results, then use <code>num_rows</code>, like this:</p>
  <pre><code>$stmt-&gt;store_result();
  $stmt-&gt;num_rows;
  </code></pre>
  <p>However, I'm running, and issue with the page bugging out when I put that code in there. I haven't even been able to get to the next step of how to display the number of rows</p>
  <p>What am I missing in terms of calculating the number of rows inside the prepared statement, then how would I display it with a <code>&lt;?php echo '# rows: '.$WHATGOESHERE;?&gt;</code></p>