Ask Question

Menu

PHP source code for count number of rows in a SQL table

<!DOCTYPE html>
<html>
<head>
<title>Count number of rows</title>
</head>
<body>
<?php
$conn=mysqli_connect("127.0.0.1:3306","root","","admin");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="select count('user_id') from login_user";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_array($result);
echo "$row[0]";
mysqli_close($conn);
?>
</body>
</html>






Subscribe with us to get latest topic update






Choose a Language



Subscribe