我正在制作一个系统,我需要查看每个学生的信息。当我单击按钮时,我需要知道学生的代码并打开包含学生信息的页面(seeStudent.php)。有人可以帮我吗?
<?php
$sql = $conn->query("SELECT * from tb_coordinator inner join tb_teacher
on tb_coordinator.cd_coord = tb_teacher.cd_coord
inner join teacher_class on
tb_teacher.cd_teacher = teacher_class.cd_teacher
inner join tb_teacher on
teacher_class.cd_class = tb_class.cd_class
inner join tb_student on
tb_class.cd_class = tb_student.cd_class
where tb_teacher.cd_cpf = '$cpf' and nm_class = '3a1' order by cd_number asc");
while($row = mysqli_fetch_array($sql)){
$nm_student = $row['nm_student'];
$cd_number = $row['cd_number'];
?>
<ul class="list-group list-group-flush" style="width: 50%; margin-top: 2%;">
<div id="load_student">
<li class="list-group-item"><?php echo $cd_number . " - " . $nm_student;?>
<a href="students.php" ><button type="button" class="btn btn-outline-info" style="margin-left: 90%;">Get Information</button></a></li>
</div>
</ul>
</div>
<?php }?>
答案 0 :(得分:1)
您需要在准备好的HTML中进行一些修改。将所需的参数添加到锚点href
中,这可能有助于您从seeStudent.php
页的数据库中获取学生详细信息。
<ul class="list-group list-group-flush" style="width: 50%; margin-top: 2%;">
<div id="load_student">
<li class="list-group-item"><?php echo $cd_number . " - " . $nm_student;?>
<a href="seeStudent.php?cd_number=<?=$cd_number?>&nm_student=<?=$nm_student?>" >
<button type="button" class="btn btn-outline-info" style="margin-left: 90%;">Get Information</button>
</a>
</li>
</div>
</ul>
如果您单击Get Information
按钮,将使用两个seeStudent.php
参数($_GET
)带您进入cd_number, nm_student
。
现在完成最后一个任务。在seeStudent.php
页面中,从$_GET
数组中获取参数,并执行其他查询以从数据库中获取学生详细信息并进行显示。
seeStudent.php
<?php
$cd_number = isset($_GET['cd_number']) ? $_GET['cd_number'] : '';
$nm_student= isset($_GET['nm_student']) ? $_GET['nm_student'] : '';
// .... code stuff, possibly query and display
?>