参考下面的图片,如果有人能抽出时间帮助我,我会很高兴。我想选择Section Location,例如Sales Floor,它将选择相应的sectionLocationID并将其附加到Dropdown输入框标记的Section Location右侧的小下拉框中。我正在使用查询在下拉框中检索值:SELECT locationName,locationID FROM locationDetails ORDER BY locationName
以下是整个代码 //准备声明 if($ stmt = $ sqlcon-> prepare(" SELECT locationName,locationID FROM locationDetails ORDER BY locationName")){
$stmt->execute();
//get result
$result = $stmt->get_result();
}
echo "<select name='clocation' class='input username'>";
echo '<option placeholder="'.$placeholdergender.'">'.$placeholdergender.'</option>';
while($row=$result->fetch_row())
{
$section=$row['0'];
// $sectionID=$row['1'];
echo '<option value="'.$section.'">'.$section.'</option>';
}
// echo '<input type="text" value="'.$sectionID.'">';
echo '</select>';
echo '<select>';
echo "<select name='cID' class='input username'>";
// echo '<option placeholder="'.$placeholdergender.'">'.$placeholdergender.'</option>';
while($row=$result->fetch_row())
{
// $section=$row['0'];
$sectionID=$row['1'];
echo '<option value="'.$sectionID.'">'.$sectionID.'</option>';
}
// echo '<input type="text" value="'.$sectionID.'">';
echo '</select>';
echo '<br>';
?>