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

  • SEARCH
  • Home
  • 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 8191813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:00:04+00:00 2026-06-07T04:00:04+00:00

i need to make a php code for checking hotel room avaibility where user

  • 0

i need to make a php code for checking hotel room avaibility where user from the present day can book rooms upto 90 days or less and there are total 30 rooms available in the hotel,so if once i store the data for a user like his booking from one date till another next time if i want to check the avaibility how should i do it in php,what would be the logic.

obviously i simple query like this isn’t correct
for eg

$this->db->select('*')
    ->from('default_bookings')
    ->where('booking_from <',$input['fromdate'])
    ->where('booking_till >',$input['tilldate']);
  • 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-06-07T04:00:06+00:00Added an answer on June 7, 2026 at 4:00 am

    I assume, you want to find free space in you booking-calendar.

    So you have a start-date and an end-date. You look in every room and make the following assumptions:

    1. The startdate and/or the enddate should not be present in an confirmed booking-period.
    2. There is no period between the start-date and the end-date.

    A SQL-Query could look like this:

    Table bookings {
        int booking_id
        int room_id
        datetime reservation_start
        datetime reservation_end
        ...
    }
    
    SELECT
        COUNT(*)
    FROM
        bookings AS test1
    WHERE
        room_id={$roomId}
        AND
        {$startdate} NOT BETWEEN reservation_start AND reservation_end
        AND
        {$enddate} NOT BETWEEN reservation_start AND reservation_end
        AND
        reservation_start NOT BETWEEN {$startdate} AND {$enddate};
    

    Is the result is 0, then there is no intersection with existing reservations.

    You can also automate the “looking into rooms” by using this query as a sub-query.

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

Sidebar

Related Questions

I've got a problem with a CKEditor plugin. I need PHP code to make
I am having problems calling a URL from PHP code. I need to call
what is wrong with this code: I need to make one array from lines
I need to make this data variable global: $.ajax({ url: get_data.php, cache: false, dataType:
I need to make a false referrer to certain pages using PHP. In my
In part of my PHP application, I need to make an REST style API
I would like make a script using PHP (probably need JS) to send POST
I need rewrite this url http://adresa.com/article.php?act=view&id=1113 to http://adresa.com/view/1113 I make it with mod_rewrite in
I need to make sure when the user hits back with, for example, the
I am migrating my PHP code to Ruby and at some point I need

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.