我在这段代码中有问题:
`
<?php echo "Choose a date";
$reservation_date = $rm->retrieveReservation();
$data_date = array();
while($row_date = mysql_fetch_assoc($reservation_date)){
array_push($data_date, $row_date);
$dateOptions = ""
. "<select class='filter'>"
. "<option value='<?php echo $row['date'] ; ?>'><?php echo $row['date'] ; ?></option>"
. "</select>";
echo $dateOptions;
} ?>
?>
我想在下拉菜单中输出Sql行值。提前致谢!
最佳答案
您不必在一段时间内回显<select>
,您应该这样做:
<?php echo "Choose a date";
$reservation_date = $rm->retrieveReservation();
$data_date = array();
$dateOptions = "<select class='filter'>";
while($row = mysql_fetch_assoc($reservation_date)){
array_push($data_date, $row_date);
$dateOptions = "<option value='". $row['date']."'>". $row['date'] ."</option>";
} ?>
$dateOptions = "</select>";
echo $dateOptions;
?>