如何将输入作为 Table 并在 Mysql Table 中提交

How to take Input As Table and Submit in Mysql Table

我正在尝试制作一个成绩管理系统,我从 Mysql 数据库中获取学生姓名,每个学生都有一个唯一 ID。我想将其渲染为 Table 行和列。 我也完成了,但是我如何使用 $_POST 并将其保存在 Mysqli 中,因为有 100 + 个值。 我做的事情是:

        php

   while ($student_row = mysqli_fetch_assoc($res){
        <input type = "number" name = "mark1-<?php echo $student_row['roll']">
        }

我已经完成,现在我通过 $_POST 获取所有值,但是很难定义每个变量然后将其提交给 MySql Table.

如果我可以使用任何库,请告诉我。

喜欢给定的图片:

这可能会有所帮助,即使问题不是很清楚(对我而言),但如果您这样输入姓名:

<input name="students[id_of_the_student][ppt]"/>
<input name="students[id_of_the_student][ma]"/> 
<input name="students[id_of_the_student][nb]"/>...

您的 post var:

中会有这个
var_dump($_POST["students"]);
/*
array(1) { // quantity of students in table
  [id_of_student]=> array(2)//number of inputs
  {
    [ppt] = "PPT value",
    [ma] => "MA value"
  }
}
*/

编辑:您的 table/form 应该是这样的:

<form id="form-students" method="POST" >
    <table>
        <thead>
            <th>PPT</th>
            <th>MA</th>
            <th>MB</th>
            <!-- And so on... -->
        </thead>
        <tbody>
            <?php while($student_row = mysqli_fetch_assoc($res)) : ?>
                <tr>
                    <?php foreach ($student_row as $key => $value) : ?>
                        <td><input type="text" name="students[<?= $student_row['id'] ?>][<?= $key ?>]" value="<?= $value ?>"></td>
                    <?php endforeach ?>
                </tr>
            <?php endwhile;?>
        </tbody>
    </table>
</form>

<?php 
$students = $_POST['students'];
?>