如何从选择表单输入中显示的值发布不同的值

On my webpage i have the below form. I am using some PHP to display the name of users in the select input. My question is this... how do I save down the id column (that I am selecting in the SQL) to the database instead of the name columns that I am displaying? All help greatly appreciated.

<form action='insertmodule.php' method='POST'>
                <span class="form-group">
                    <input type="text" placeholder="Name" class="form-control" name="name" required/>
                </span>
                <br>
                <div class="form-group">
                   <label for="exampleSelect1">Select the tutor for the module</label>
                    <select class="form-control" name="tutor">
                      <?php
                        include('../connections/conn.php');
                        $sql = mysqli_query($conn, "SELECT id, first_name, last_name FROM cater_users WHERE role = 2");
                        while ($row = $sql->fetch_assoc()){
                        echo "<option>" . $row['first_name'] . " ". $row['last_name'] . "</option>";
                        }
                      ?>
                    </select>
                 </div>


                <button type="submit" class="btn btn-primary" name='sign'>Create</button>
            </form>
查看全部
dpy83214
dpy83214
2018/04/03 14:45
  • php
  • html
  • forms
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复