Answers for "php count sql results"

PHP
1

php 7 count result in database

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("host", "username", "password","db_name");
mysqli_set_charset($link, "utf8mb4");

$result = mysqli_query($link, "SELECT count(*) FROM blackandwhite");
$num_rows = mysqli_fetch_row($result)[0];

echo "$num_rows Rows\n";
Posted by: Guest on November-18-2020
1

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

count sql query in php

$sql = "SELECT COUNT(*) AS total from Members";
$result = $conn->query($sql);
$data =  $result->fetch_assoc();
echo $data['total'];
Posted by: Guest on December-23-2020

Browse Popular Code Answers by Language