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

    }
?> 

This is the design of drop down,

enter image description here

2 Answers 2

1

add [ ] tag to name tag, so you will get your value in array.

<option name='deluxe[]'>$x</option>
Sign up to request clarification or add additional context in comments.

Comments

0

First thing that I notice is that in you select statement, you cannot have value as an attribute. Please check the documentation select tag

And the option tag does not include name attribute. Please check the documentation option tag

If you want to get multiple values from a drop down list. Please check this article

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.