+ Reply to Thread
Results 1 to 5 of 5




  

Thread: PHP MySQL help!

      
  1. #1
    Jedi Master articweb is on a distinguished road
    Join Date
    April 19, 2008
    Location
    Gloucestershire - UK
    Posts
    101
    Rep Power
    5
    Feedback Score
    0

    Question PHP MySQL help!

    I have a booking calendar database with the following fields:

    booking_id (foreign Key linking to Bookings table)
    calendar_startdate
    calendar_enddate
    calendar_status



    So the booking obviously takes up all the dates between the startdate and enddate and there can only be one booking on each date.

    I then have a form for users to make a booking request with the fields "start date" and "end date" this checks the database to see if the date range entered (between startdate and enddate) is available or not.

    But I am not too sure how to do it. Any help or suggestions would be great.
    Website Stats | Website Hosting | SEO Blog

    Got Computer Problems? Need help or remote support?

  2. #2
    Super Moderator tsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to behold tsdesigns's Avatar
    Join Date
    February 6, 2008
    Location
    Scotland
    Posts
    1,078
    Rep Power
    6
    Feedback Score
    0

    Default Re: PHP MySQL help!

    I assume they are all date fields in the database? Well, apart from the ID (which I guess is a tinyint? Or a number none the less).

    Reading this tutorial would probably help a lot. You'll need to set up a counter between the first date and the last date to do what you want, adding to the day all the time:
    PHP Tutorial - Date

  3. #3
    Jedi Master dvduval has a spectacular aura aboutdvduval has a spectacular aura aboutdvduval has a spectacular aura about dvduval's Avatar
    Join Date
    January 14, 2007
    Posts
    317
    Rep Power
    6
    Feedback Score
    0

    Default Re: PHP MySQL help!

    So did you have any luck writing the PHP code?
    (I wasn't sure if you are a php programmer already?)
    Directory Script -easy to create and profitable too Demo
    Template Forums - find templates for phpLD
    phpLD Site of the Month Winners - see some great directories
    phpLD Hosting - our top hosting pick for phpLD users

  4. #4
    Jedi Master Paramiliar is on a distinguished road Paramiliar's Avatar
    Join Date
    July 24, 2007
    Location
    West Midlands
    Posts
    105
    Rep Power
    5
    Feedback Score
    0

    Default Re: PHP MySQL help!

    One method would be to use the following query for each day

    Code:
    SELECT COUNT(*) 
    FROM tablename 
    WHERE calendar_startdate <= 2009-08-09 
    AND calendar_enddate >= 2009-08-09
    This will then fetch the number of bookings on that date, if there is a count of more than 1 then you know the date can not be booked.

    I would also create seperate indexs on both date fields to speed up the search. The reason you do a COUNT(*) is because it is a LOT quicker to count the number of rows than it is to fetch data and use a mysql_num_rows, infact if you benchmark this for a year (365) it still takes less time than it does for mysql_num_rows to do the same task for a month!
    Matthew Bagley
    Paramiliar Design Studios
    IT Consultant | Website Design | Website Development

  5. #5
    Jedi Master vikas1234 is on a distinguished road
    Join Date
    June 10, 2009
    Posts
    147
    Rep Power
    3
    Feedback Score
    0

    Default Re: PHP MySQL help!

    working with date in mysql is always problem I prefer to use datediff function
    FREE BOOKS - Collection of free Books and free books download | free online pdf books - Collection of free online pdf Books and free pdf ebooks | Occultism Books - Free Occultism Books and Ebooks | Engineering Questions - All engineering jobs interview questions

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. mysql question
    By komrad in forum HTML & Website Design
    Replies: 3
    Last Post: Apr 16th, 2009, 6:08 am
  2. Remote Mysql
    By grim in forum HTML & Website Design
    Replies: 3
    Last Post: Dec 16th, 2008, 6:58 pm
  3. access to mysql
    By Toom in forum HTML & Website Design
    Replies: 1
    Last Post: Aug 20th, 2008, 3:22 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads