*我想从下拉列表中获取数据,就像我选择了代理ID和代理名称来获取数据库中的数据我将代理ID存储在数据库表中 代理ID中的错误未存储在数据库中
<?php
$sql = mysqli_query($con, "SELECT agent_name From agent order by agent_id");
$row = mysqli_num_rows($sql);
while ($row = mysqli_fetch_array($sql)){
echo "<option value='" . $row['agent_id'] . "'>" . $row['agent_name'] . "</option>";
}
?>
</select>
<label>Agent</label>
<select class="form-control" name="agent_name" id="agent_name">
答案 0 :(得分:-3)
<?php
$sql = mysqli_query($con, "SELECT agent_name,agent_id From agent order by agent_id");
$num = mysqli_num_rows($sql);
?>
<label>Agent</label>
<select class="form-control" name="agent_name" id="agent_name">
<?php
while ($row = mysqli_fetch_array($sql)){
echo "<option value='".$row['agent_id']."'>".$row['agent_name'] . "</option>";
}
?>
</select>