2
我使用查詢結果填充了下拉框的選項。用戶提交後如何保留選定的值?提交後保留查詢生成的下拉框的值
下面的代碼:
$query="SELECT trainingName,trainingID FROM training ORDER BY trainingName";
$result = mysql_query ($query);
echo "<select name='training' value=selected>Training Name</option>";
$training = strip_tags(@$_POST['training']);
echo "<option>---------------------Select---------------------</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[trainingID]>$nt[trainingName]</option>";
}
謝謝!
http://stackoverflow.com/questions/9339225/how-do-retain-value-of-dropdown-box-in-php – CodeZombie 2012-02-22 09:40:11