php(ex02c.php)
<?php
if(isset($_GET['name'])&&isset($_GET['sex'])){
$ID = $_GET['name'];
$sex = $_GET['sex'];
$conn=mysqli_connect("localhost","root","123","text3") or die("数据库连接失败");
mysqli_query($conn,'set names utf8');
$sql3="select * from student where id='$ID' and sex='$sex'";
$result=mysqli_query($conn,$sql3)or die("数据查询失败");
$conn->close();
}
?>
<div style="position: absolute;height: 60%; 70%;left: 20%;top: 15%">
<form action="ex02b.php" method="post">
<table border="1" style="height: 100%; 100%">
<tr>
<td style="text-align: center" colspan="3">
个人信息
</td>
</tr>
<tr>
<td>您的姓名:</td>
<td colspan="2"><?php foreach ($result as $value){echo $value['id'];break;}?></td>
</tr>
<tr>
<td>性别:</td>
<td><?php foreach ($result as $value){echo $value['sex'];break;}?></td>
</tr>
<tr>
<td>家庭住址:</td>
<td colspan="2">
<input name="area" type="text" value="<?php foreach ($result as $value){echo $value['area'];break;}?>">
</td>
</tr>
<tr>
<td>
特长爱好:
</td>
<td colspan="2">
<input name="hobby" type="text" value="<?php foreach ($result as $value){echo $value['hobby'];break;}?>">
</td>
</tr>
<tr>
<td colspan="3" style="text-align: center">
<a href="ex02a.php">返回首页</a>
</td>
</tr>
</table>
</form>
</div>