How to count number of rows and display that number?
<p>Lets say for example there are 5 records shown on screen. I want the $questionnum to display the number 5, but it keeps stating that $questionnum is 0. How Can I get the number of the number of rows actually match with the number of rows which are outputted on screen. E.G if 5 rows then display number 5, if 3 rows display number 3 and etc.</p>

<p>Below is code:</p>

<pre><code> // Execute
    if (!$stmt-&gt;execute()) {
      die("Error executing statement: $stmt-&gt;error"); 
    }

    $stmt-&gt;store_result();

    // This will hold the search results
    $searchResults = array();
    $searchOption = array();

    // Fetch the results into an array
    if (!$stmt-&gt;num_rows()) {
      $stmt-&gt;bind_result($dbQuestionContent,$dbOptionType); 
      while ($stmt-&gt;fetch()) {
        $searchResults[] = $dbQuestionContent;
        $searchOption[] = $dbOptionType;
      }
    }

    if (isset($_GET['searchQuestion'])) {

      // If $terms is not empty we did a query
      if (!empty($terms)) {

          $questionnum = $stmt-&gt;num_rows;

        // If $searchResults is not empty we got results
        if (!empty($searchResults)) {
         echo"&lt;p&gt;Number of Questions Shown from the Search: &lt;strong&gt;$questionnum&lt;/strong&gt;&lt;/p&gt;";
          echo "&lt;table border='1' id='resulttbl'&gt;
          foreach ($searchResults as $key=&gt;$question) {
            echo '&lt;tr class="questiontd"&gt;&lt;td&gt;'.htmlspecialchars($question).'&lt;/td&gt;';
            echo '&lt;td class="optiontypetd"&gt;'.htmlspecialchars($searchOption[$key]).'&lt;/td&gt;';
    }
          echo "&lt;/table&gt;";
    }
</code></pre>
