从数据库中获取数据第二个文件结果集

<?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();
原文地址:https://www.cnblogs.com/qingxiaoping/p/5020092.html