Mysql COUNT() Functions Query

The COUNT() function returns the number of records in a select query.

To understand COUNT function, consider an products table, which is having following query

First you can need database connection in php

Code

$sql = "SELECT COUNT(id) FROM Products"; 
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result))
{

}

Leave a Reply

Your email address will not be published. Required fields are marked *