Answers for "how to count number of entries in sql php"

PHP
2

get count sql query in php

$result=mysql_query("SELECT count(*) as total from Students");
$data=mysql_fetch_assoc($result);
echo $data['total'];
Posted by: Guest on February-18-2021
0

mysql count rows php

<?php
$con = mysqli_connect("localhost","root","","test");
if (!$con) 
{
  die('Could not connect: ' . mysqli_error());
}

$result = mysqli_query("select COUNT(*) FROM table");
$row = mysqli_fetch_array($result);

$total = $row[0];
echo "Total rows: " . $total;

mysqli_close($con);
?>
Posted by: Guest on February-17-2022

Code answers related to "how to count number of entries in sql php"

Browse Popular Code Answers by Language