title: How do I get the $num_rows variable to work
body: <p>Everything in my code works but $num_results...</p>
  
  <p>
  
      Book-O-Rama Search Results
  
  
      <h1>Book-O-Rama Search Results</h1>
      
  
  <pre><code>    //create short variable names
      $searchtype=$_POST['searchtype'];
      $searchterm=$_POST['searchterm'];
      $searchterm=trim($searchterm);
  
      if (!$searchtype || !$searchterm) {
          echo 'You have not entered search details. Please go back and try again.';
          exit;
      }
      if (!get_magic_quotes_gpc()) {
          $searchtype = addslashes($searchtype);
          $searchterm = addslashes($searchterm);
      }
  
      include "../common/inc/db_connect_books.php";
  
      //$db = new mysqli_connect('localhost', 'root', '', 'books');
  
      $sql = "SELECT * FROM books WHERE ".$searchtype." LIKE '%".$searchterm."%'"
          or die(mysql_error());
  
      $result = $dbh-&gt;query($sql);
  
      $num_results = $result-&gt;num_rows;
  
      echo '&lt;p&gt;Number of books found: '.$num_results.'&lt;/p&gt;';
  
      foreach ($result as $row) {
          echo '&lt;p&gt;&lt;b&gt;'.($i+1).'. Title: ';
          echo htmlspecialchars(stripslashes($row['title']));
          echo '&lt;/b&gt;&lt;br&gt;Author: ';
          echo stripslashes($row['authors']);
          echo '&lt;br&gt;ISBN: ';
          echo stripslashes($row['isbn']);
          echo '&lt;br&gt;Price: ';
          echo stripslashes($row['price']);
          echo '&lt;/p&gt;';
  
          $result-&gt;free();
          $dbh-&gt;close();
      }
  ?&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>PLease help</p>