im trying to create an update form. below is my html for year manufactured and vehicle status.
<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>
";
}
?>
</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>
";
if($row['yearManufactured']==$year){
echo "selected";
}
}
?>
</select>
</div>
in the vehicle status, i used selected to makesure that the values of inserted data is displayed in the update form. is it also the same for the year manufactured? i tried to put selected inside the option field but it gave me error. how can i use selected inside foreach for the year manufactured?