使用复选框将数据放入数据库

时间:2019-02-08 09:06:06

标签: php html

我正在制作一个项目,用户可以在其中创建时间表并将其发布,因此我在旁边的日期和日期使用了一个复选框,我在网上找到了此代码,可能无法理解它的流程我知道它是如何工作的,我可以创建自己的..

<?php
            include('../dist/includes/dbcon.php');
            $query=mysqli_query($con,"select * from time where days='mwf' order by time_start")or die(mysqli_error());

            while($row=mysqli_fetch_array($query)){
                    $id=$row['time_id'];
                    $start=date("h:i a",strtotime($row['time_start']));
                    $end=date("h:i a",strtotime($row['time_end']));
    ?>
                          <tr >
                            <td><?php echo $start."-".$end;?></td>
                            <td><input type="checkbox" id="check" name="m[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="w[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="f[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>

                          </tr>

    <?php }?>                     
    </table> 

我知道他是如何从数据库中获取数据的,问题是他如何将数据输入数据库中。名为schedule的数据库具有这些字段(time_id,days,subject),因此可以理解的是,当用户检查m时,将在几天内输入数据,但是他如何输入time_id?时间数据库包含这些字段(time_id,time_start,time_end),因此,基本上,如果用户选择的time_id为1的7:00-8:00,然后选择W,则时间表数据库将类似于以下sched_id = 1,time_id = 1,天= w ..但是我应该怎么写呢?预先感谢

0 个答案:

没有答案