Error - mysqli_num_rows

-1

Hello

I want to check the number of records in the database and display the number of records on the screen, but it is not working, what could be wrong?

   <?php

   include '../include/connection.php';

   $query = "SELECT id FROM user ORDER BY id ASC";

   $result = mysqli_query($link, $query) or die(mysql_error());

   $rows = mysqli_num_rows($result);

   while ($row = mysqli_fetch_array($result))
   {

      echo $rows;

   }
 ?>

Thank you

    
asked by anonymous 08.11.2016 / 23:50

1 answer

0

As I see it, to display the record count:

   include '../include/connection.php';
   $query = mysqli_query($link, "SELECT id FROM user ORDER BY id ASC") or print mysql_error();
   $rows = mysqli_num_rows($query);
   echo "Total de registros: ".$rows;
    
08.11.2016 / 23:57