ex01b:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>个人信息</title>
</head>
<style>
tr{
text-align: center;
}
</style>
<body>
<table border="1" cellpadding="5" cellspacing="0" ">
<tr>
<td colspan="7"><p>学生个人信息表 </p></td>
</tr>
<tr>
<td>姓名</td>
<td>性别</td>
<td>爱好</td>
<td>住址</td>
<td>备注</td>
<td colspan="2">操作</td>
</tr>
<tr>
<?php
include_once('conn.php');
$sqlstr = "select * from phpstu";
$result = mysqli_query($conn,$sqlstr);
while ($rows = mysqli_fetch_row($result)){
echo "<tr>";
for($i = 0; $i < count($rows); $i++){
echo "<td >".$rows[$i]."</td>";
}
echo "<td><a href='ex01b_update.php?name={$rows[0]}&sex={$rows[1]}&hobby={$rows[2]}&address={$rows[3]}&beizhu={$rows[4]}'>修改</a>/<a href='ex01b_delete.php?name={$rows[0]}'>删除</a></td>";
echo "</tr>";
}
?>
</tr>
</table>
</body>
</html>
ex001a:
<?php
header ( "Content-type: text/html; charset=utf-8" ); //设置文件编码格式
include_once('conn.php');
$name=$_POST['name'];
$sex=$_POST['sex'];
$hobby=$_POST['hobby'];
$address=$_POST['address'];
$beizhu=$_POST['beizhu'];
$sql = "insert into phpstu(name,sex,hobby,address,beizhu)values('{$name}','{$sex}','{$hobby}','{$address}','{$beizhu}')";
$result=mysqli_query($conn, $sql);
if($result){
echo "<script>alert('添加成功');window.location.href='ex01b.php'</script>" ;
}else{
echo "<script>alert('添加失败');history.go(-1);</script>";
}
?>