PHP提交动态名称的单选按钮值

时间:2014-12-21 22:28:45

标签: php html

我已经浏览了网络以寻找答案,并查看了Stack Overflow,但尚未找到解决我问题的可行解决方案。首先发布Stack Overflow,请耐心等待我!

我正在用PHP编写一个基本的考勤程序,每个成员都可以选择现在,迟到或缺席。该页面当前从数据库生成活动成员列表,并且每个页面都有一组单选按钮,其中包含可能的选项(显示,延迟或不存在)。

我遇到的问题是如何将值传递到数据库中以获取动态成员列表。由于成员是动态的,我如何将这些成员添加到数据库中?

修改

根据要求,以下是页面上的一些示例代码,它们根据成员生成单选按钮,但我的问题源于如何将这些值传递到数据库中。

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Members
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover">
                                <form action = "attendanceProcess.php" method="post">
                                <thead>
                                    <tr>
                                        <th>Name</th>
                                        <th>Present</th>
                                        <th>Late</th>
                                        <th>Absent</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $sql = "SELECT ID, firstName, lastName, status FROM members WHERE status='1' OR status='2' OR status='3'";
                                        $result = mysql_query($sql);
                                        if (mysql_num_rows($result) > 0) { 
                                           while($row = mysql_fetch_assoc($result)) {
                                                if($row['status'] == 1) {

                                                    $status = "<span class=\"label label-success pull-right\">" . statusIDtoStatusName($row['status']) . "</span>";
                                                }
                                                if($row['status'] == 2) {

                                                    $status = "<span class=\"label label-primary pull-right\">" . statusIDtoStatusName($row['status']) . "</span>";
                                                }
                                                if($row['status'] == 3) {

                                                    $status = "<span class=\"label label-warning pull-right\">" . statusIDtoStatusName($row['status']) . "</span>";
                                                }

                                                // Present = 1
                                                // Late = 2
                                                // Absent = 3


                                                echo "<tr class=\"odd gradeX\"><td>" . $row['firstName'] . " " . $row['lastName'] . " " . $status . "</td><td><input type=\"radio\" name=\"". $row['ID'] ."\" value=\"1\"></td><td><input type=\"radio\" name=\"". $row['ID'] ."\" value=\"2\"></td><td><input type=\"radio\" name=\"". $row['ID'] ."\" value=\"3\"></td></tr>";
                                            }                                                                                            
                                        } else {
                                            echo "0 results";                                       
                                        }         
                                        ?> 

                                </tbody>
                            </table>
                                    <input type="submit" value="Submit"><br />      
                                </form>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>

1 个答案:

答案 0 :(得分:-1)

会员存储在一个表中?

UPDATE `TABLE` SET `status` = "$status" WHERE `member_id` = "$id"