<?php
/医院
*1创建数据库
* 2准备SQL语句
* 3创建出预处理对象STMT
* 4检测STMT,预处理的SQL语句对象
* 5执行SQL语句
*/
require 'mysqli_connect.php';
$sql = "update ignore staff set salary=? where staff_id=?;";
$stmt = $mysqli->stmt_init();
if($stmt->prepare($sql)){
$stmt->bind_param('si',$name,$salary);
$salary=8800;
$staff_id=17;
$stmt->execute();
if($stmt->affected_rows>0){
echo '<br>插入成功'.$stmt->affected_rows.'条记录,id:'.$stmt->insert_id;
}else{
echo '<br>没有新增记录';
}
}else{
exit($stmt->errno.":".$stmt->error);
}点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号