title: PHP Count search result from mysql database
body: <p>I have a php script doing a search record from mysql database, how can i add a count for total query return from mysql? eg. i search &quot;ABC&quot;, total search results are 3, i want to display this after the search &quot;total search found: 3&quot;. Have been trying below code so far and not making any good progress, anyone can can assist? Thanks</p>
  <pre><code>&lt;?php
  define('DB_HOST', 'localhost');
  define('DB_NAME', 'stock');
  define('DB_CHARSET', 'utf8mb4');
  define('DB_USER', 'root');
  define('DB_PASSWORD', '');
  
  try
  {
      $pdo = new PDO(&quot;mysql:host=&quot; . DB_HOST . &quot;;charset=&quot; . DB_CHARSET . &quot;;dbname=&quot; . DB_NAME, DB_USER, DB_PASSWORD, [PDO::ATTR_ERRMODE =&gt; PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE =&gt; PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES =&gt; false]);
  }
  catch(Exception $ex)
  {
      die($ex-&gt;getMessage());
  }
  
  $stmt = $pdo-&gt;prepare(&quot;SELECT * FROM `data` WHERE `Name` LIKE ? OR `shopfront_signage` LIKE ? &quot;);
  
  $stmt-&gt;execute([&quot;%&quot; . $_POST['search'] . &quot;%&quot;, &quot;%&quot; . $_POST['search'] . &quot;%&quot;]);
  
  $results = $stmt-&gt;fetchAll();
  if (isset($_POST['ajax']))
  {
      echo json_encode($results);
  }
  
  //$resultscount= $results[0];
  //echo $resultscount;
  $query = mysqli_query($stmt);
  $resultrow = mysqli_num_rows($query);
  echo 'Total search found: ' . $resultrow;
  
  ?&gt;
  </code></pre>