Chapter 5
Online Catalog Application
In This Chapter
Designing Web pages that display products
Building the database to store product information
Writing procedural code for the Catalog application
Developing and using objects to program the Catalog application
he online catalog application is one of the most common applications on
the Web. Whether the Web site is offered by an individual with a handful
of products or a huge company with gazillions of products, the principle is
the same. The customer needs to see the products and information about
them before buying anything.
On many Web sites with catalogs, customers can purchase the catalog items
online. In this chapter, I provide a catalog application that doesn’t include
online purchasing functionality. The application in this chapter only displays
the catalog. The application in Chapter 6 is an online purchasing application,
which provides the ability to purchase catalog items online.
Designing the Online Catalog Application
The basic function of the online catalog application is to display a store’s
products to the customers. If a store offers only a dozen products, you can
just display them all on one page. However, a store generally offers many
products, more than you can reasonably display on a single Web page.
Usually, the products are categorized. A small number of products can be suc-
cessfully categorized by one category level. If the store offers a large number
of products, however, you might need to use two, three, or more category
levels to successfully categorize the products into categories small enough
to be displayed. For instance, the example in this chapter is a store that sells
food products. I use two category levels for this example. Foods are catego-
rized first at the high category level, such as fruit, vegetables, herbs, and so
on. Second levels within the high level of fruit might be apple, orange, and
cherry. The product might be Delicious or Granny Smith, which would be in
the category fruit: apple.
11_575872 ch05.qxd 5/27/05 6:20 PM Page 131
If your products are categorized, the online catalog typically first displays a
page showing the categories available. The customer can select a category to
see all the products in that category. If you have several levels of categories,
the customer might need to select successive categories before reaching the
product Web page.
Even with categories, some stores might have many products in a single
category. For instance, Sears probably has many products in the category
“Dresses” or even “Evening Dresses.” A common practice when displaying
a large number of products is to display only a certain number of products
(often ten) on a page. The customer clicks a button to see the next set of
products or the previous set of products.
To meet its basic functionality, the online catalog application should
Display the product categories from which the user can select.
Display the products in the category the user selects. It should display
all the product information (price, description, and so on) needed by the
customer. It should display the products one page at a time if the prod-
uct list is quite long.
Creating the Catalog Database
The application design calls for a database that stores product information.
The database is the catalog, the core of this application. The database stores
the product names, ordering numbers, description, price, and any other rele-
vant information, such as size, color, and so on.
Designing the Catalog database
Your first design task is to select the information you want to store. What you
store depends on the type of product. You need to store any information that
a customer might use when deciding which product to purchase. The store
owner, who knows the products and what customers need to know, can pro-
vide this information along with graphics of the products. Some possible
information to store might include
Product name: Obviously, customers will need this information.
Product ID: In most cases, the product name is not unique, so you usu-
ally need to store a product number, a unique number that identifies the
product to the purchaser.
Product description: A text description of the product.
Part III: Building Online Sales Applications
11_575872 ch05.qxd 5/27/05 6:20 PM Page 132

Get PHP & MySQL® Everyday Apps For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.