批改状态:合格
老师批语:
<?php
/**
* Created by PhpStorm.
* User: xuan
* Date: 2018/6/6
* Time: 11:25
*/
header("Content-type:text/html;charset=utf-8");
require('conf.php');
// 写一条预处理模型
$sql = "select * from user where user_id=?; ";
$id =3;
// 开始预处理
$stmt =mysqli_stmt_init($db);
// 判断预处理 模型语句对或者错
if(mysqli_stmt_prepare($stmt,$sql)){
@mysqli_stmt_bind_param($stmt,'i',$id);
if(@mysqli_stmt_execute($stmt)){
}else{
echo '没有该记录';
}
//获取结果集
mysqli_stmt_store_result($stmt);
//绑定结果集
@mysqli_stmt_bind_result($stmt,$name,$id);
// 遍历结果集
if(@mysqli_stmt_num_rows($stmt) > 0){
while(mysqli_stmt_fetch($stmt)){
echo "[{$name}] => {$id}]<br>";
}
}else{
echo '没有查询到记录';
}
}else{
exit('模型语句出错');
}点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号