<?php $mysqli=new mysqli("localhost", "root", "123456", "xsphpdb"); $stmt=$mysqli->prepare("select id, name, price, num, desn from shops where id>?"); $stmt->bind_param("i", $id); $stmt->bind_result($id, $name, $price, $num, $desn); $id=99; $stmt->execute(); $stmt->store_result(); //一次性将结果都取过来 重要 //字段信息 $result=$stmt->result_metadata(); while($field=$result->fetch_field()){ echo $field->name."--"; } echo ‘<br>‘; //记录信息 //$stmt->data_seek(2); while($stmt->fetch()){ echo "$id--$name---$price---$num---$desn <br>"; } echo "记录总数:".$stmt->num_rows; $stmt->free_result(); $stmt->close();
时间: 2024-10-13 00:22:49