views:

100

answers:

3

I am very new to php and MySql, but I am writing a project for school on ticket reservation. I need help with:

  1. creating a table in a db that has specified number of rows and the rows increase by mulitples of the specified number (Example: say I have a table for Bus A that has 15 seats so I want d db table to contain 15 rows but has the ability to add new 15 rows if a different date is selected)

  2. checking the table with specified number of rows to see the rows that have not been filled with data from a form, echoing the ids of the empty rows and inserting new for data into any available empty row.

  3. get data from a form and insert it into different tables in a db.

I know this is cumbersome, but I will be glad if anybosy can help me. Let me know if the question is clear.

Thanks...

+2  A: 

Creating one table per one bus (or whatever) is not really a good idea, you should start with some documentation how to design database structures.

Michal Čihař
A: 

I aggree with the above statement "Creating one table per one bus (or whatever) is not really a good idea"

You need to redesign the complete database, to work more efficiently.

The way you have mentioned may work but database wont be normalised. If you require any help, you can contact me.

Crickey
A: 

First you'll need to think a little about what information you'd like to capture. From that you can design your database. A simplistic start could be:

specs: capture data about reserved tickets (event, row number, who, ..)

db:

  • users (id, name, ..)
  • events (id, name, event_date, number_of_seats, ...)
  • reservations (id, event_id, user_id, seat_number, reservation_date, ...)

With this db you should be able to answer (through sql statements) most (if not all) questions you could ask about the above specs. Obviously this has some flaws, google the therms 'event planner database design' and you'll find what you need.

Cheers

jodorovski