我找到了一个关于如何从数据库中获取数据以选择在 PHP 中保存到数据库中的值的模型,但是它不起作用,有人可以就以下代码提供建议吗?
<?php
$tempoSEL = array("","","","","","","","","","");
if($row['tempo'] == "1"){
$tempoSEL[1] = " selected='selected' ";
}else if($row['tempo'] == "2"){
$tempoSEL[2] = " selected='selected' ";
}else if($row['tempo'] == "3"){
$tempoSEL[3] = " selected='selected' ";
}else if($row['tempo'] == "4"){
$tempoSEL[4] = " selected='selected' ";
}else if($row['tempo'] == "5"){
$tempoSEL[5] = " selected='selected' ";
}else if($row['tempo'] == "6"){
$tempoSEL[6] = " selected='selected' ";
}else if($row['tempo'] == "7"){
$tempoSEL[7] = " selected='selected' ";
}else if($row['tempo'] == "8"){
$tempoSEL[8] = " selected='selected' ";
}else if($row['tempo'] == "9"){
$tempoSEL[9] = " selected='selected' ";
}
$db = PageDB::getInstance();
?>
<p>
<label style="padding-right:28px;">Tempo</label>
<select name="tempo">
<option value="1" <?php echo $tempo[1]; ?>>2 Sec</option>
<option value="2" <?php echo $tempo[2]; ?>>5 Sec</option>
<option value="3" <?php echo $tempo[3]; ?> selected>10 Sec</option>
<option value="4" <?php echo $tempo[4]; ?>>20 Sec</option>
<option value="5" <?php echo $tempo[5]; ?>>30 Sec</option>
<option value="6" <?php echo $tempo[6]; ?>>45 Sec</option>
<option value="7" <?php echo $tempo[7]; ?>>60 Sec</option>
<option value="8" <?php echo $tempo[8]; ?>>90 Sec</option>
<option value="9" <?php echo $tempo[9]; ?>>120 Sec</option>
</select>