Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:53:24+00:00 2026-05-27T04:53:24+00:00

What is a simple way to check for room availability? I have been working

  • 0

What is a simple way to check for room availability?

I have been working on a little project for class, just a simple, small hotel registration page that needs contact information and billing information. Bear in mind that unencrypted information is not an issue here.

Here is part of my process.php page:

$sql="INSERT INTO UMBRELLA (firstName, lastName, email, arrivalDate, 
departureDate, adultGuests, childGuests, roomReservation, newsletterBool, 
comments, creditCardType, creditCardNumber, expirationMonth, expirationYear, 
securityCode, phone)
VALUES
('$_POST[firstName]','$_POST[lastName]','$_POST[email]', '$_POST[arrivalDate]', 
'$_POST[departureDate]', '$_POST[adultGuests]', '$_POST[childGuests]', 
'$_POST[roomReservation]', '$_POST[newsletterBool]', '$_POST[comments]',
'$_POST[creditCardType]', '$_POST[creditCardNumber]', '$_POST[expirationMonth]', 
'$_POST[expirationYear]', '$_POST[securityCode]', '$_POST[phone]')";

I would prefer to keep the solution simple, as it’s only a minor requirement, so I don’t want to create additional tables for a many-to-many relationship (e.g. ROOMS table, BOOKINGS table). The roomReservation value only has three options: 1. Presidential Suite 2. Master Suite 3. Standard Suite. Basically, I would like to create a variable, $maxRooms, that is equal to 10.

$maxRooms=10;

I would then use a SELECT statement to get all useful data for each specific room type (note this is pseudocode so some formatting might be off):

$standard = "SELECT arrivalDate, departureDate, roomReservation FROM UMBRELLA 
WHERE roomReservation = 'Standard Suite';"

$master = "SELECT arrivalDate, departureDate, roomReservation FROM UMBRELLA 
WHERE roomReservation = 'Master Suite';"

$presidential = "SELECT arrivalDate, departureDate, roomReservation FROM 
UMBRELLA WHERE roomReservation = 'Presidential Suite';"

I would then check how many rooms are reserved in a given date range, and if it was >=maxRooms then the page would output an error. This is the part I’m having trouble on. I would appreciate any help or insight! Thank you!

tl;dr What code do I need to compare the $standard, $master, and $presidential variables to a given date range?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:53:24+00:00Added an answer on May 27, 2026 at 4:53 am

    So, they will be telling you which type of room they would like through something like a select input?
    ie:

        <select>
            <option value="presidential">Presidential Suite</option>
            ....</select>
    

    The max rooms: Does that refer to there being 10 master suites, 10 standard suites, and 10 presidential suites for a total of 30 rooms in all? If not, and it’s only 10 rooms in the whole ‘hotel’ how are the distributed across the three types? Also, I’m assuming you would not like the database to upload the new reservation if the rooms are full.

        $maxRooms = 10;
        $fetchQuery = "SELECT room_reservation FROM UMBRELLA 
                  WHERE room_reservation = '$_POST[roomReservation]'";
        $fetchResult = mysql_query($fetchQuery);
        $numberRooms = mysql_num_rows($fetchResult);
            if($numberRooms >= $maxRooms)
            {
                echo "error: All ".$_POST['roomReservation'."s are currently booked.";
            }
            else
            {
                $insertQuery = "INSERT into UMBRELLA VALUES('$_POST[firstname]',.....)";
                mysql_query($insertQuery) or die(mysql_error());                        
                echo "Registration Complete.";
            }
    

    So, when someone clicks “Make Reservation” or whatever your submit button on the form is called, this checks to ensure the room type they have chosen is available. If it’s not they are they are all booked. If there are open rooms of the type they chose, they are reserved the room (which adds to the current number of rooms reserved of that type making it one less for the next) etc. You’d have to write something for checking out etc obviously.

    Something like this? Honestly, I haven’t tried it etc…but is this the idea you are going for? I hope it helps a bit maybe…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

C# .net Framework 4.0 Is there a simple way to check if you have
Is there a simple way to check if my template has been optimized out?
Is there a simple way to check the type of an object? I need
I need an simple way to check whether a string that is sent to
Is there a quick and simple way to check if a key exists in
Is there any simple way to programatically colorize images in .NET? Basically we have
What is the simple way to check google username and password whether it is
Is there a simple way to check how many times a character appears in
I am trying to find a simple way to check if an IP address
In .NET, is there a simple way to check whether the current user has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.