Php 带有单选按钮的简单考勤系统

Php 带有单选按钮的简单考勤系统,php,time-and-attendance,Php,Time And Attendance,我正在制作一个简单的考勤系统 我这里有一个带有单选按钮的php代码。。现在我把它放在桌子上 我只能在整个表中选择一个单选按钮,而不是每个注册帐户选择一个单选按钮 <?php session_start(); if(!isset($_SESSION["in"])) { header("Location: log.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:

我正在制作一个简单的考勤系统

我这里有一个带有单选按钮的php代码。。现在我把它放在桌子上

我只能在整个表中选择一个单选按钮,而不是每个注册帐户选择一个单选按钮

<?php
session_start();
if(!isset($_SESSION["in"]))
{
    header("Location: log.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Attendance</title>

</head>
    <body>
<center>
<br />
<?php
echo "Today is " . date("m/d/Y") . "<br><br><br><br>";
?>

<?php
$conn= new mysqli("localhost", "root", "", "dbform");

    $sql = "SELECT * FROM tblusers";



$result = $conn->query($sql);
if ($result->num_rows > 0) {
    echo "<table width='1300' border='6'> 

<tr>
<th width='100'>ID</th>
<th width='100'>Lastname</th>
<th width='100'>Firstname</th>
<th width='100'>Sex</th>
<th width='100'>Attendance</th>
</tr>";
     // output data of each row
     while($row = $result->fetch_assoc()) {
         echo "<tr> ";
echo "<td align='center'>2016" . $row['id'] . "</td>";
echo "<td align='center'>" . $row['lastname'] . "</td>";
echo "<td align='center'>" . $row['firstname'] . "</td>";
echo "<td align='center'>" . $row['sex'] . "</td>";
?>
<form method="post" action="Succes_Submit_Attendace.php" name="submit_attendance">

attendance = 
<td align='center'> <label><input type="radio" name="attendance" value="present">Present</label>
              &emsp;<label><input type="radio" name="attendance" value="absent">Absent</label><br /><br />

<?php  

$row['attendance'] ;

?> </td>
<?php 
echo " </tr>";

     }
     echo "</table>";
} 
else {
     echo "0 results";
}
$conn->close();
?>   
<br>
<br>
<input type="reset">&emsp;<input type="submit" value="Submit Attendance"></h4>
</form>


<div align="right">
 <a href="admin.php"><h3>Back</h2></a>
</div>

出勤

出席人数= 目前 &emsp;缺席



&emsp;

所有单选按钮都具有相同的名称,因此您需要按行id对它们进行分组。将输入类型更改为以下类型:

<label><input type="radio" name="attendance[<?php echo $row['id']; ?>]"  value="present">Present</label> 
&emsp;
<label><input type="radio" name="attendance[<?php echo $row['id']; ?>]" value="absent">Absent</label><br /> <br />

@AnkiiG在while之前打开表单标记loop@EnsiehParsaeian我在回答中已经提到,代码中有HTML错误需要修复。我只提供了问题的解决方案。