此功能是将值插入数据库。首先,它会列出类“$class”中的所有学生。界面如下:
//我不能发布图片,因为我没有太多的声誉。但是,该界面将列出所有学生的列“NO”、“Birth No”、“Student Name”、“Attendance”。在列考勤中,会显示 3 个单选按钮,即 PT、AT、MC。表外有一个提交按钮。
问题是,当我单击两个学生的单选按钮后单击提交按钮时,数据库中没有插入任何内容。
$id = 1;
$getdata = mysql_query("select * from student where class = '$class' order by name ")     or die(mysql_query);
while($row = mysql_fetch_assoc($getdata))
    {
        if(isset($_POST['a'.$id])) 
        {
            $status = $_POST['a'.$id];      
            if(!empty($status))
            {
                if($status == "present")
                {
                    $attend = 1;
                }
                else if($status == "absent")
                {
                    $attend = 0;
                }
                else if($status == "mc")
                {
                    $attend = 1;
                }
                $query = "INSERT INTO attendance VALUES ('$birth_no','$date','$status','$attend')";
                if($query_run = mysql_query($query))
                {
                    echo 'Insert attendance done';
                }
                else
                {
                    echo'Attendance not inserted.';
                }                   
            }
            else
            {
                echo 'Please enter all fields';
            }
        }
        else
        {
            //FORM CODE HERE
            ?>
            <form action="addattend.php" method = "POST">
            <?php
                $birth_no= $row['birth_no'];
                $name = $row['name'];
                    ?>
                    <tr>
                        <td><center><?php echo $id ?></center></td>
                        <td><center><?php echo $date ?></center></td>
                        <td><center><?php echo $birth_no ?></center></td>
                        <td><center><?php echo $name ?></center></td>
                        <?php
                    echo'<td>
                            <input type="radio" name="a'.$id.'" value="present">PT
                            <input type="radio" name="a'.$id.'" value="absent">AT
                            <input type="radio" name="a'.$id.'" value="mc">MC
                        </td>
                    </tr> ';
        }
        $id++;      
    }
            ?>
            </table>
            <center><input type="submit" value="Submit"></center>
            </form>
            <?php
有人可以帮我解决这个问题吗?我尝试解决这个问题一个星期。但是什么也没出来。真的很感谢你的好意。谢谢你。