如果您在使用這個 num_rows 時遇到問題,您必須先宣告 ->store_result()。
<?php
$mysqli = new mysqli("localhost","root", "", "tables");
$query = $mysqli->prepare("SELECT * FROM table1");
$query->execute();
$query->store_result();
$rows = $query->num_rows;
echo $rows;
// 例如,返回 4
?>