-1
即時嘗試創建更新表單。下面是我的製造年份和車輛狀態的HTML。更新值PHP
<div class="form-group">
<label class="control-label" >Year Manufactured:</label>
<select class="form-control" name="yearManufactured" value="<?php if(isset($row['yearManufactured_vehicle'])) { echo $row['yearManufactured_vehicle']; } ?>">
<option>Select</option>
<?php
foreach(range(1950, (int)date("Y")) as $year) {
echo "\t<option value='".$year."'>".$year."</option>\n\r";
}
?>
</select>
</div>
<div class="form-group">
<label>Vehicle Status</label>
<select class="form-control" name="yearManufactured" value="<?php if(isset($row['yearManufactured_vehicle'])) { echo $row['yearManufactured_vehicle']; } ?>">
<option>Select</option>
<?php
foreach(range(1950, (int)date("Y")) as $year) {
echo "\t<option value='".$year."'>".$year."</option>\n\r";
if($row['yearManufactured']==$year){
echo "selected";
}
}
?>
</select>
</div>
在車輛狀態中,我用來選擇確保插入數據的值以更新形式顯示。製造年份也是一樣嗎?我試圖把選擇內的選項字段,但它給了我錯誤。我如何使用製造年份內的選擇內部foreach?
請包括錯誤 – Swellar
,你可以直接呼應'selected',而不是關閉了'php',然後鍵入它 – Swellar
@Swellar的我編輯的代碼,並把選擇的。仍然沒有變化。我如何解決這個問題? – yuki