下拉菜单中的验证

时间:2019-05-31 09:50:08

标签: php sql validation dropdown

在表单中,我必须选择成员,但是我想在表单中进行验证,以使用户有义务在代码中选择成员

下面是我的代码摘要:

<?php

$conn = new mysqli('localhost','root','password','database') or die ('Cannot connect to db');

$result = $conn->query("select member_id, name from member");

echo "<html>";
echo "<body>";
echo "<select name='member_id' class='form-control' style='width:500px;'>";
echo '<option value="">Choose Member</option>';

while ($row = $result->fetch_assoc()) {
    unset($member_id, $name);
    $member_id = $row['member_id'];
    $name = $row['name']; 

    echo '<option value="'.$member_id.'">'.$name.'</option>';
}

echo "</select>";
echo "</body>";
echo "</html>";

?>

0 个答案:

没有答案