码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-12-04 20:14:32      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

<?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();

 

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

标签:

原文地址:http://www.cnblogs.com/qingxiaoping/p/5020092.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!