在表单中,我必须选择成员,但是我想在表单中进行验证,以使用户有义务在代码中选择成员。
下面是我的代码摘要:
<?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>";
?>