Pagination Consternation
by Jake Vinson
in Feature Articles
on 2009-07-23
Bruno was working on a PHP-based hotel reservation system and, thanks to the odd bug here and there, seldom had the time to look into the "feature requests" queue. But the good news was that the system was getting more and more stable with each release, and the really good news was that Bruno would be getting some help from a newly hired developer named Greg. Bruno even picked out the perfect first task for the new guy.
The system worked as you'd expect any online hotel reservation system to work – punch in the name of a city (optionally including the number of nights for your stay, smoking/nonsmoking preference, etc.), get a list of hotels back matching the criteria. Clicking the "Find Hotels" button would fire off a few operations; first retrieving a list of hotels from the database, then some light massaging of the list in PHP code, then writing out the results to the page. It was all well and good until you did a search for hotels in New York City, where you'd get a near-endless page with hundreds of hotels. The obvious, simple solution? Split up the results into multiple pages.