要查询MySQL数据的数量,可以使用以下方法:
$query = "SELECT COUNT(*) as count FROM users";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
$count = $row['count'];
$query = "SELECT * FROM users";
$result = mysqli_query($connection, $query);
$count = mysqli_num_rows($result);
$query = "SELECT * FROM users";
$result = $pdo->query($query);
$count = $result->rowCount();
无论使用哪种方法,都可以得到MySQL数据的数量。
上一篇:php交互mysql需要转义吗
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站