<?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>";

    }
?>

这是下拉菜单的设计
php - 如何从循环中获取下拉的多个值?-LMLPHP

最佳答案

我注意到的第一件事是,在select语句中,不能将value作为属性。请检查文档select tag
并且option标记不包含name属性。请检查文档option tag
如果要从下拉列表中获取多个值。请检查this article

10-07 19:14
查看更多