select
失败后如何保留input
submit
的选项?
<select name = "state" id="selector1" class="form-control1">
<option value = "0">Select staff State of Origin</option>
<?php
$states_sql = "SELECT state, state_id FROM states ORDER BY state ASC LIMIT 0,36";
$state_query = $cxn->query($states_sql);
if($state_query->num_rows != 0){
while($state = $state_query->fetch_object()){
<option value = "<?php echo htmlspecialchars($state->state_id); ?>">
<?php echo htmlspecialchars_decode($state->state);
?>
</option>
<?php
}
}
?>
</select>
答案 0 :(得分:0)
您的查询应如下所示
<select name = "state" id="selector1" class="form-control1">
<option value = "0">Select staff State of Origin</option>
<?php
$states_sql = "SELECT state, state_id FROM states ORDER BY state ASC LIMIT 0,36";
$state_query = $cxn->query($states_sql);
if($state_query->num_rows != 0){
while($state = $state_query->fetch_object()){
echo '<option value="'. htmlspecialchars($state->state_id).'">' .
htmlspecialchars_decode($state->state) .
'</option>';
}
}
?>
</option>
</select>