Hi, am new in the forum. Please I need help concerning a hotel booking system am developing. The problem is when custumer wants to make room choice it can only allow 1 type of room when the available room information loads. If a customer wants to book 2 or more rooms but diffetype of room (maybe 1 suite and 1 single) they cant do so. The system can only handle reservation for the same room type for the number of room wanted. The code snippet is shown below.

<label style="margin-left: 11px;"><strong>Enter Number of rooms Needed: </strong></label>
                    <INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="no_rooms" class="ed">
                        <span id="errmsg"></span>
                            <br />
                            <br />
                                <?php
                                $con = mysql_connect("localhost","root","");
                                if (!$con)
                                  {
                                  die('Could not connect: ' . mysql_error());
                                  }

                                mysql_select_db("reserve", $con);

                                $result = mysql_query("SELECT * FROM room");

                                while($row = mysql_fetch_array($result))
                                  {
                                  $a=$row['room_id'];
                                  $query = mysql_query("SELECT sum(qty_reserve) FROM roomin where arrival <= '$arrival' and departure >= '$departure' and room_id='$a'");
                                while($rows = mysql_fetch_array($query))
                                  {
                                  $inogbuwin=$rows['sum(qty_reserve)'];
                                  }
                                  $angavil = $row['qty'] - $ino;
                                  echo '<div style="height: 117px;">';
                                      echo '<div style="float: left; width: 100px; margin-left: px;">';
                                      echo "<img width=120 height=90 alt='Unable to View' src='" . $row["image"] . "'>";
                                      echo '</div>';
                                      echo '<div class="cleaner_h20">&nbsp;</div>';
                                      echo '<p><div style="float: left; width: 575px; margin-top: -10px;">';
                                      echo '<span class="style5">'.'Avalable Rooms: '.$avil.'</span>';
                                      if ($angavil > 0){
                                                    echo '<input name="roomid" type="checkbox" value="' .$row["room_id"]. '" />';
                                                    echo '<input type="submit" name="Submit" value="reserve" onclick="setDifference(this.form);"/>';
                                                    }
                                                if ($avil <= 0){
                                                echo '<span class="style5">'.'check vacant'.'</span>';
                                                }   
                                      echo '<br>';       
                                      echo '<span class="style5">'.'Room Type: '.$row['type'].'</span><br>';
                                      echo '<span class="style5">'.'Room Rate: '.$row['rate'].'</span><br>';
                                          echo '<span class="style5">'.'Max Child: '.$row['max_child'].'</span><br>';
                                          echo '<input name="mchild" type="hidden" value="' .$row["max_child"]. '" />';
                                        echo '<input name="avail" type="hidden" value="' .$angavil. '" />';
                                      echo '<span class="style5">'.'Max Adult: '.$row['max_adult'].'</span><br>';
                                          echo '<input name="madult" type="hidden" value="' .$row["max_adult"]. '" />';
                                      echo '<span class="style5">'.'Room Description: '.$row['description'].'</span><br>';
                                       echo '<div class="cleaner_h20">&nbsp;</div>';
                                        echo '<div class="cleaner_h20">&nbsp;</div>';
                                      echo '</div>';
                                  echo '</div>';
                                }

                                mysql_close($con);
                            ?> 
                                <input type="hidden" name="result" id="result" />
                        </form>

Bold Text Here

Have you tried making the option of selecting rooms to be a check box??

This way, a user can select more than one choice.

I think the reason as to why you are being able to reserve only one room is because you have two different buttons for submitting.

Perhaps you could get rid of one button, so that the user has the freedom of choosing as many rooms as they want, and yet only submit once.

Thank you for the reply, I thought that was the issue bu I dont know how to code the page to include both type of room with different prices. Because the customer have to pay for the room. Am okay up to this stage to pay for only 1 type of room even if its 10 booked. But the real issue here is that I dont have idea of how to write the code to allow for mix rooms. Thanks again.

I think, the first thing that you should do is to eliminate the option of someone entering the number of rooms they want. Because they may decide to enter 3, and yet select only one.

As for the code. You dont have to change alot from your code. Leave the checkboxes the way they are. Just get rid of the two buttons that are besides the checkbox for rooms.

Then at the bottom add only one submit button;

<input type="submit" value="Submit" id="submit">

Hope that helps.

Thank you for your patience, i will try that and i will let you know if it works

k. Best of luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.