每日总结5.12

<html>
<head>
<meta charset="UTF-8">
<title>学生信息管理</title>

</head>
<body>
<center>
<?php
// .连接数据库
try{
$pdo = new PDO("mysql:host=localhost;dbname=test;","root","251233");
}catch(PDOException $e){
die("数据库连接失败".$e->getMessage());
}
// .防止中文乱码
$pdo->query("SET NAMES 'UTF8'"); // .拼接sql语句,取出信息
$sql = "SELECT * FROM info WHERE id =".$_GET['id'];
$stmt = $pdo->query($sql);//返回预处理对象
if($stmt->rowCount()> 0 ){
$stu = $stmt->fetch(PDO::FETCH_ASSOC);//按照关联数组进行解析
}else{
die("没有要修改的数据!");
}
?>
<form id="editstu" name="editstu" method="post" action="act.php?action=edit">
<input type="hidden" name="id" id="id" value="<?php echo $stu['id'];?>"/>

<table>
<tr style="background: #666666;font-size: 30px ;text-align: center">
<td colspan="2">修改学生信息</td>
</tr>
<tr>
<td>姓名</td>
<td><input id="name" name="name" type="text" value="<?php echo $stu['name'];?>"/></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="sex" value="男" />男
<input type="radio" name="sex" value="女" />女
</td>
</tr>

<tr>

<td>兴趣爱好</td>
<td><input type="text" name="hobby" id="hobby" value="<?php echo $stu.['hobby']?>"/></td>
</tr>

<tr>

<td>家庭住址</td>
<td><select id="address" name="address" >
<option value ="">请选择您的居住区域</option>
<option value ="上海">上海</option>
<option value="广州">广州</option>
<option value="北京">北京</option>
</select></td>
</tr>
<tr>
<td>备注</td>
<td><textarea id="remark" name="remark" rows="5" cols="30">
</textarea></td>
</tr>
<tr>
<td><input type="submit" value="修改"/>  </td>
</tr>
</table>

</form>

</center>
</body>
</html>
原文地址:https://www.cnblogs.com/wanghaoning/p/14914745.html