Skip to Content
Web Database Applications with PHP and MySQL, 2nd Edition
book

Web Database Applications with PHP and MySQL, 2nd Edition

by Hugh E. Williams, David Lane
May 2004
Intermediate to advanced
820 pages
24h 34m
English
O'Reilly Media, Inc.
Content preview from Web Database Applications with PHP and MySQL, 2nd Edition

Chapter 18. The Shopping Cart

In this chapter, we introduce the shopping cart developed for the online winestore. The shopping cart is typical of those used in online stores: the user can add items to the cart and manage the quantities of the different items. However, it's also a little different: unlike many other implementations, the cart data is stored in database tables, and one session variable per user tracks the cart's identity.

This chapter is the third of five that outline the complete winestore application. We present here the four scripts that manage the shopping cart and a fifth script that produces the home page of the winestore. The scripts in this chapter perform the following functions:

Display the home page

Shows new wines that have recently been reviewed. The script also includes embedded links that allow the user to add items to their cart; this is one part of the one-component querying strategy discussed in Chapter 6, and the other part is a feature of the script that adds items to the cart, discussed next.

Add items to the cart

Adds a quantity of a specific wine to the user's shopping cart. This illustrates database writing and locking techniques discussed in Chapter 8 and one component querying discussed in Chapter 6.

View the shopping cart

Queries the database and displays the contents of the user's shopping cart. This demonstrates basic querying techniques from Chapter 6, combined with the winestoreFormTemplate class discussed in Chapter 16.

Empty the cart

Deletes ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Database Applications with PHP, and MySQL

Web Database Applications with PHP, and MySQL

Hugh E. Williams, David Lane
Learning PHP and MySQL

Learning PHP and MySQL

Michele E. Davis, Jon A. Phillips

Publisher Resources

ISBN: 0596005431Supplemental ContentErrata Page