One of the many benefits of using databases is that they are scalable. At the moment, the Newland Tours database contains profiles for 16 countries. However, over time the business could grow, and contain profiles of 40 or even 60 countries. Even at 16, the complete listing of country profiles on a single Web page is too much for most users to wade through. In most cases, users are not interested in all of the countries, but rather only a subsetthe ones they are considering visiting. The same applies to the tour descriptions themselves and even more broadly to most database data on the Web. Imagine going to Amazon.com if you had to download and display millions of products on a single page!
For this reason, it's important when developing dynamic Web sites to make it easy to filter data, so that users can see the data that they want to see. You can enable your site's visitors to filter data in many different ways, from simple URL parameters to full-blown search engines. In this, and the next two lessons, you'll build several different interfaces that give you control over how you display data to users.
The entire country profile is pulled dynamically from the database, identified using the URL variable countryid=5, and formatted on the fly using CSS.
In this lesson, you will use URL parameters (also known as querystrings) to filter data. You used this technique back in Lesson 5 (Passing Data Between Pages) when you built the cat person/dog person widget. But that was a toy to demonstrate a point. In this lesson, you'll not only filter results based on a URL parameter, but you'll also dynamically generate the hyperlinks themselves, including the linked text the user sees and the unique URL parameters for each.
Like many dynamic Web applications, this one is split into two pages. On the first page, users click the URL for the country profile they want to see. On the second, the appropriate country profile is displayed. But again, the majority of the information on both pages is dynamically generated. The advantage to this approach is that once you've built the two-page application, maintaining it is as simple as updating the database itselfno one will need to revise either page if a country is added, removed, or renamed (it happens).
WHAT YOU WILL LEARN
In this lesson, you will:
Create a two page application that filters and displays database data
Dynamically generate URLs
Layout multiple elements populated with dynamic data
Display images dynamically
Create repeating dynamic data regions
Hand-code SQL to combine filtered data from multiple tables
This lesson takes approximately two hours to complete.