Php 我正在制作一个在线考勤系统
每当我标记学生出席时,它会标记所有出席的学生,我如何保存它?Php 我正在制作一个在线考勤系统,php,mysql,Php,Mysql,每当我标记学生出席时,它会标记所有出席的学生,我如何保存它? 这是在线考勤管理系统的代码。您需要更改三件事: 您仅从数据库中选择名称。你也应该 选择主键(即学生id) 一旦您有了学生id,就可以对表单元素的名称进行造型,以模仿类似数组的结构 在PHP代码中,可以使用key/value foreach循环遍历数组的每个id和值 对于上面的步骤2,您应该从以下内容修改现有代码: <?PHP session_start(); $_SESSION["teac
这是在线考勤管理系统的代码。您需要更改三件事:
<?PHP
session_start();
$_SESSION["teacher"] = "tech01";
echo "Favorite teacher is " . $_SESSION["teacher"] . ".<br>";
include 'db.php';
?>
<html>
<head></head>
<body>
<?php
if(isset($_POST['submit']))
{
$inst=$_POST['inst'];
$sub=$_POST['sub'];
$view_student="select s_name from students where s_inst='$inst' AND
s_sub='$sub' ";
$run=mysqli_query($dbcon,$view_student);
echo "<form name='form' action='atte.php' method='post'>";
echo '<input type="date" name="att">'; // currently for future use
echo "</br>";
while($row=mysqli_fetch_array($run)){
$name=$row['s_name'];
echo '<input type="checkbox" name="present" >';
echo "<label>" .$name. "</label>";
echo "<input type='hidden' name='stun' value='".$name."'/>";
echo "<input type='hidden' name='inst' value='".$inst."'/>";
echo "<input type='hidden' name='sub' value='".$sub."'/>";
echo '<input type="submit" value="Submit_attendance"
name="insert">';
echo "<br>";
}
echo "</form>";}
?>
我已经更新了我的代码,以防您遇到问题。非常感谢,它正在工作
echo '<input type="checkbox" name="present" >';
echo "<input type='checkbox' name='present[{student_id}]' >";
foreach($_POST['present'] as $student_id => $present) {
if ($present) {
echo "The student with id of $student_id is present";
}
}