我有一个显示座位号的动态组合框。我有一个从组合框中扣除选定值的 for 循环。
function display_seatNo() {
$query = "SELECT * FROM table1 WHERE ID = 1";
$result = mysql_query($query) or die("Failed to fetch records");
$rows = mysql_fetch_array($result);
$seatNo = $rows['SeatNo'];
$totalSeat = $rows['TotalSeats'];
$seatReserved = $rows['SeatsReserved'];
$remain = $totalSeat - $seatReserved;
$length = count($remain);
for($i=1; $i<=$remain-1; $i++){
echo "<option value=\"$i\" ";
echo " $i";
echo "> $i </option>";
}
}
<select name="cbSeatNo" id="cbSeatNo" class="cb1">
<?php display_seatNo(); ?>
</select>
问题是所选值没有消除。示例:- 预留座位号 1 后,它不应显示在组合框中。