Sorting Data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sparky256DSL
Forum Newbie
Posts: 1
Joined: Wed Nov 14, 2007 3:02 pm

Sorting Data

Post by sparky256DSL »

I want to sort ticket information from a database (Section, Row, Seat). I can retrieve the data from the database but what would be the best way to find consecutive seats? I want someone to be able to type in that they want 4 seats and it finds the four best seats (based on row number) that are consecutive seat in the same section. Any help would be great.


Thanks
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Sorting Data

Post by califdon »

sparky256DSL wrote:I want to sort ticket information from a database (Section, Row, Seat). I can retrieve the data from the database but what would be the best way to find consecutive seats? I want someone to be able to type in that they want 4 seats and it finds the four best seats (based on row number) that are consecutive seat in the same section. Any help would be great.
It all depends on how your seating plan is constructed. If the seating is divided into Sections and Rows, and if the Sections are different across aisles, you should be able to determine whether seats are adjacent if they are in the same Section, the same Row, and have consecutive seat numbers (or 2 apart, if odds are on one side and evens on the other).

If seat designations are arbitrary, I'd suggest that you assign a "contiguous-seats-section" code to each seat and store it in a table. Then you could search for continuous numbers within a contiguous-seats-section.
Post Reply