1,连接数据库
try{
// mysql数据类行;dbname=数据库;post:端口号;charset=utf8:设置字符集;用户名;密码
$conn=new PDO("mysql:host=localhost;dbname=mycalss;port=3306;charset=utf8",'root','root');
}catch(PDOException $e){
echo "输出异常".$e->getMessage();
}
//设置的function.php文件方便重复用到
修改
<?php
//连接数据库
require "function.php";
//执行SQLy语句(修改语句);
$sql="update my_student set stu_name=:name,sex=:sex,age=:age,birthday=:birthday where studentid=:id ";
//预处理
$stmt=$conn->prepare($sql);
$name=$_POST['name'];
$age=$_POST['age'];
$sex=$_POST['sex'];
$birthday=$_POST['birthday'];
$id=$_POST['id'];
//绑定参数:array(":name"=>$name,":sex"=&