<?php
// this is where selecting of number of rooms in database
$sql = mysqli_query($con, 'SELECT * FROM roomtype');
$get_room1 = mysqli_query ($con, "SELECT * from room where status='Activated' and type_id=2");
$get_room2 = mysqli_query ($con, "SELECT * from room where status='Activated' and type_id=3");
$get_room3 = mysqli_query ($con, "SELECT * from room where status='Activated' and type_id=4");
$get_room4 = mysqli_query ($con, "SELECT * from room where status='Activated' and type_id=5");
$standard = mysqli_num_rows($get_room1);
$deluxe = mysqli_num_rows($get_room2);
$family = mysqli_num_rows($get_room3);
$regular = mysqli_num_rows($get_room4);
// this is the loop for the drop down and it will display the number of rooms available
while($row = mysqli_fetch_array($sql))
{
$a=$row['type_id'];
$b = $row['rmtype'];
$_SESSION['room_type'] = $row['rmtype'];
echo '<div style="height: 300px;">';
echo '<div style="float: left; width: 100px; margin-top: 15px; margin-left: 60px;">';
echo "<img width=250 height=200 alt='Unable to View' src='" . $row["image"] . "'>";
echo '</div>';
echo '<div class="well" style="float: right; width: 780px; margin-top: 5px;">';
echo '<div style="float: right;">';
echo '</div>';
echo '<br />';
echo "<label style='margin-left: px;'>Number of rooms:";
echo "<select name='select_no_rooms[]' value='" .$row['rmtype']." ' />";
echo "<option> </option>";
if ($row['rmtype']=="Standard Room")
{
for ($x = 1; $x<=$standard; $x++){
echo "<option name='standard'>$x</option>";}
}
if ($row['rmtype']=="Deluxe Room")
{
for ($x = 1; $x<=$deluxe; $x++){
echo "<option name='deluxe'>$x</option>";}
}
if ($row['rmtype']=="Family Room")
{
for ($x = 1; $x<=$family; $x++){
echo "<option name='family'>$x</option>";}
}
if ($row['rmtype']=="Regular Room")
{
for ($x = 1; $x<=$regular; $x++){
echo "<option name='regular'>$x</option>";}
}
echo "</select>";
}
?>
这是下拉设计,
答案 0 :(得分:1)
将[ ]
标记添加到名称标记,这样您就可以在数组中获取值。
<option name='deluxe[]'>$x</option>
答案 1 :(得分:0)
我注意到的第一件事是,在select
语句中,您不能将value
作为属性。请查看文档select tag
option
标记不包含name
属性。请查看文档option tag
如果您想从下拉列表中获取多个值。请检查this article