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 4085920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:39:06+00:00 2026-05-20T18:39:06+00:00

i want to create a php with mysql to do the following: lets say

  • 0

i want to create a php with mysql to do the following:

lets say that i have a shop i want to rent, rent will be weekly or monthly. I’m searching for the best way to create this table, so i can do easy queries to calculate free weeks or months.

EDIT

let say i have

ID, START_DATE,RENING_TYPE,CLIENT_ID

where Start_date is the start date for renting, and RENTING_TYPE is weekly or monthly

how should i run a query to know all the empty weeks or month so new clients may reserve that week/month

for example a client reserve July month another client reserve the first week in June, if a new client logged in to my system and want to check all the available weeks/months, how can i achieve that ?

  • 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-20T18:39:07+00:00Added an answer on May 20, 2026 at 6:39 pm

    This query should return all the free intervals between bookings. It gets all suspected free days (end day + 1) if they have not already been booked, then it searches to find the next booked day. Giving you output like this

    Start Free | End Free
    -----------------------
    2011-02-03 | 2011-02-06
    2011-02-08 | 2011-02-12
    2011-02-20 | 2011-03-02
    

    You can then get the exact dates inbetween using PHP.

    The query:

    SELECT DATE_ADD(r2.end_date, INTERVAL 1 DAY), 
    (
        SELECT DATE_SUB(MIN(starting_date), INTERVAL 1 DAY)
        FROM renting_table as r1
        WHERE r1.starting_date > r2.end_date
    )   
    FROM renting_table as r2
    WHERE DATE_ADD(end_date, INTERVAL 1 DAY) not in
    (
        SELECT r3.start_date
        FROM renting_table as r3
    )
    

    Note: I’m very rusty with SQL so the syntax will probably be off but I think the logic is sound. I hope this gives you a nod in the right direction at least!

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

Sidebar

Related Questions

I want to create a static class in PHP and have it behave like
I have a website which uses PHP and HTML pages, I want to create
I'm currently working on a PHP/MySQL script that does the following, in this order:
I want to create a number of links within a page that have different
I want to create a file on the webserver dynamically in PHP. First I
I want to create a CAPTCHA similar to http://www.gigbooks.com/getcaptcha.php this one. But its in
I want to use php in console mode and create an environment to test
I want to create a function that performs a function passed by parameter on
I want to create a simple http proxy server that does some very basic
I have a PHP MySQL application which has a modular design. There are about

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.