Jump to content

table with changing values everyday


penguinsource

Recommended Posts

I'm not completely sure how to implement this so I'd like to ask you to give me an idea if you can

For a tennis booking system.. it will look something similar to (should be a table but this is for the sake of the idea)

 

        Date: Oct 25th, 2010  (go to oct 26)

            Court 1                Court 2      Court 3        Court 4

 

8:00    Open(bookit)    Tally                Open          Hellio

9:00    Andy                  Roger            Barney        Training

...etc

 

Now everyday, this table should be empty, so new bookings can be made

how would I make it so a new table is empty /or has dif bookings every day (based on date) efficiently?

 

Im guessing I will have dif values in the sql table for dif dates but what I'm not sure of is how to display it in page

 

for ex, if someone presses the button oct 26, the new table is for that date, wif diff values

Link to comment
Share on other sites

eeek. that doesn't sound like a good database schema.  within a year you'll have 365 tables in your database.

 

you really just need a table with a few fields, like:

 

ID (the incremental integer row identification number)

date (the date  that a court will be booked)

start_time (the time that the court will be booked)

end_time (the time that this booking ends)

court (the court name - or better yet, the ID value to a court listed in another table of "courts")

user (the user who has booked the court - or again, the ID value to a list of users and uses in another table)

 

then, you can query your database any way you want.

 

When is Court 3 being used on Oct 25?

"SELECT `user` FROM table_name WHERE date = '2010-10-25' "

 

Is Court 3 availabe at 2:45 on October 25?

"SELECT `ID` FROM table_name WHERE date = '2010-10-25' AND start_time < 2:45 AND end_time > 2:45"

 

etc...

 

(and really, you don't need that `date` column either if the start and end time columns use a full date/time format)

 

Link to comment
Share on other sites

Yea that clarifies a part. Thanks

But I'm also not sure about how to display the next booking date.

As in, if i go to Next Day, how will I link to it (as in link to the booking day that has those set values)? I guess I can just use a condition like if day = select ..etc..

 

Anyway thanks for the fast answer, this sounds good!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.