我已经制作了考勤表,其中包含从数据库中动态检索的学生卷号,姓名,在场和缺席。
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$course=$_GET['id'];
mysql_select_db('attendance');
$sql = "SELECT student.sr_no, student.roll_no, student.name , mark_attendance.percentage FROM student INNER JOIN mark_attendance ON mark_attendance.roll_no = student.roll_no WHERE student.course_name Like '$course' ORDER BY roll_no ASC";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_NUM))
{
print "<tr>";
print "<td>" . $row[0] . "</td>";
print "<td>" . $row[1] . "</td>";
print "<td>" . $row[2] . "</td>";
echo "<td>" . '<input type="checkbox" name="present[]" value= "1" />'. " </td>";//checkboxes for present
echo "<td>" . '<input type="checkbox" name="present[]" value= "0" />' . "</td>";//checkboxes for absent
print "<td>" . $row[3] . "</td>";
echo "<td>" . '<input type="text" name="remarks" value= "" />' . "</td>";
print "</tr>";
}
}
mysql_free_result($retval);
mysql_close($conn);
?>
我想让这两个复选框列表互相排斥,当我点击Present复选框时,其相应的缺席复选框变为空,副virsa。
答案 0 :(得分:1)
使用单选按钮
// radio button for present
echo '<td><label><input type="radio" name="present[' . $row[0] . ']" value="1"> present</label></td>';
// radio button for absent
echo '<td><label><input type="radio" name="present[' . $row[0] . ']" value="0"> absent</label></td>';
答案 1 :(得分:0)