hi friends!
i'm trying to convert my app from mysql to mysqli and I have a problem with this query

old (it works and it prints the total number of records)

$total = mysql_result(mysql_query("SELECT COUNT(id) FROM table"), 0);
echo $total;

new (doesn't work: it only prints the number 1)

$total = mysqli_num_rows(mysqli_query($db, "SELECT COUNT(id) FROM table"));
echo $total;

Can you help me to edit this code? thanks a lot!

    That's because the query only returns one row, so mysqli_num_rows returns "1" (as would mysql_num_rows()).
    You want to use the functionality of [man]class.mysqli-result[/man], see the comment by tuxedobob on that page.

      Write a Reply...