Hi to all,
I had a simple question, I was wanted to know what would be the best way to setup a simple table(s) to calculate guests/dates & openings avail. Meaning
if I had 4 different dates say 3-1-07, 3-2-07, 3-5-07, 3-3-07. and each one had only 50 spots avail, and when a participant registered to attend one of those dates they could choose to bring a max of 4 guests, ultimately reducing the 50 spots either by 1 or 5, whats the best way to setup a table to know when they have been filled up?...and how would one calculate this?
Kind regards, John
thanks for your reply....it only matters that the seats requested are not over the limit of seats avail. so if i have 50 spots for date 3-1-07, and 50 for 3-1-07... I need to be able to know or count whats being inserted where? and then when submitting I guess checking to see if that dates spots have been all taken. The crux is that, 1 person can bring up to 1-4 guests... so I have to account for the possibiltiy of this deduction in each date as well.
Kind regards, John
I only have been using database for few months, how would I go about drementing the value? use SQL command? when doing an insert?
can you provide an example?.
really appreciate you help and your time!, John
you will need some sort of scripting language here, no?
- receive user request
- check available total for the date requested (SELECT query)
- if greater than or equal to the number user is requesting, insert user request (INSERT statement), and decrement the available (UPDATE statement)
all the above needs to be inside a transaction block
the UPDATE statement willl look something like
SET seats = seats = $req
WHERE theday = '$date'
I think I am making progress thanks to you, I can query the DB and get the amounts of seats avail for each day, also can update the DB.
But I am having trouble decrementing the seats to reflect the changes.
Also I put another field called reqID in the day_seats table so I can know what day I am looking it. Is my thinking correct?... Moreover, how can I do insert based upon user data?, use posted variables right?...like for php $_POST["dates"]; etc...
I am a ok programmer but when comes to databases I seem to get confused...do you think databases are a harder concept than programming?