Blue Blue - 2 years ago 88
MySQL Question

Count function not counting all rows in db table

I am trying to count the number of rows in a table, using the count function. I currently have 5 rows in the table in question. However the count function is only counting 1 row. Why is this? Any suggestions.

$count_pcode = mysqli_query($dbc, "SELECT COUNT(*)FROM Delivery_Pcode");
$count_row =mysqli_num_rows($count_pcode);
printf("%d results.\n",$count_row);
mysqli_free_result($count_pcode );

Answer Source

Try the following:

$count_pcode = mysqli_query($dbc, "SELECT * FROM Delivery_Pcode");
$count_row = mysqli_num_rows($count_pcode);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download