[wd_asp elements=’search’ ratio=’100%’ id=1]

Count rows returned (mysqli) – results from database

31st May 2014

MySql

mysql codehaven category

This will count result of rows returned from the query called $result and echo it straight to screen. Instead use the variable in a div to show the user amount of results from search. Use mysqli

$sql="SELECT id FROM workers";

if ($result=mysqli_query($mysqli,$sql))
{

$rowcount=mysqli_num_rows($result);
printf("Result set has %d rows.\n",$rowcount);

mysqli_free_result($result);
}