有结果集的mysqli函数获取行数和列数
<?php $mysqli=new mysqli("localhost", "root", "123456", "xsphpdb"); if(mysqli_connect_errno()){ echo "错误:".mysqli_connect_error(); exit; } //执行select语句,返回来的就是结果集(对象) $sql="select id,name from shops where id <50"; $result=$mysqli->query($sql); $rows=$result->num_rows; $cols=$result->field_count; echo "表中{$rows}行,{$cols}列<br>"; $mysqli->close();