更新时间:2023-02-06 10:52:18
<?php
$mysqli = new mysqli("hostname", "dbusername", "dbpassword", "dbname");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($result = $mysqli->query("SELECT count(*) cc FROM tablename")) {
/* fetch the first row as result */
$row = $result->fetch_assoc();
printf("Result set has %d rows.\n", $row['cc']);
/* close result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
其实这是一个常见的问题,你可以在任何地方找到答案。
In fact it's a common question you can find the answer anywhere.
例如, http://php.net/手动/ en / mysqli-result.num-rows.php
您可以将此问题分为两个
You could separate this problem in to two