millsy007
03-03-2009, 05:39 PM
I have a coach booking program, Each Coach/Shuttle trip is made of up of journeys, on each of these passengers names are booked into a seat. For example:
shuttle_id Journey_id route_id depart_dttm seat1 seat2 seat3 seat4 seat5
1 3 3 01-01-2009 Jos Jan Joe
When I insert a record I want to insert the current passenger name into the first available seat, so for the above example it would be seat 4.
My current insert statement works by:
INSERT INTO journey
(seat1)
VALUES ('$name')
WHERE shuttle_id=$id
AND route_id=$route
Obviously this is only okay if seat 1 is available, how can I make it go into the first available/blank seat column?
Ideally I would add an extra table but alot of the program has already been produced so if I could keep the table in this format it would be great. I dont have a problem displaying the records or deleting them, it is just the part when I need to assign a passenger to a seat that is tricky. Is there something I could write that would allow this functionality?
shuttle_id Journey_id route_id depart_dttm seat1 seat2 seat3 seat4 seat5
1 3 3 01-01-2009 Jos Jan Joe
When I insert a record I want to insert the current passenger name into the first available seat, so for the above example it would be seat 4.
My current insert statement works by:
INSERT INTO journey
(seat1)
VALUES ('$name')
WHERE shuttle_id=$id
AND route_id=$route
Obviously this is only okay if seat 1 is available, how can I make it go into the first available/blank seat column?
Ideally I would add an extra table but alot of the program has already been produced so if I could keep the table in this format it would be great. I dont have a problem displaying the records or deleting them, it is just the part when I need to assign a passenger to a seat that is tricky. Is there something I could write that would allow this functionality?