Specifications

If we pass in an array containing the book data, the form will be rendered in edit mode and
will fill in the fields with the existing data:
<input type=text name=price
value=”<?=$edit?$book[“price”]:””; ?>”>
We even get a different submit button. In fact, for the edit form we get twoone to update the
book, and one to delete it. These call the scripts edit_book.php and delete_book.php, which
update the database accordingly.
The category versions of these scripts work in much the same way except for one thing. When
an administrator tries to delete a category, it will not be deleted if any books are still in it.
(This is checked with a database query.) This avoids any problems we might get with deletion
anomalies. We discussed these in Chapter 7, Designing Your Web Database. In this case, if a
category was deleted that still had books in it, these books would become orphans. We
wouldnt know what category they were in, and we would have no way of navigating to them!
Thats the overview of the administration interface. For more details, refer to the codeits all
on the CD-ROM.
Extending the Project
We have built a fairly simple shopping cart system. There are many additions and enhance-
ments we could make:
In a real online store, you would need to build some kind of order tracking and fulfill-
ment systemat the moment, theres no way to see the orders that have been placed.
Customers want to be able to check the progress of their orders without having to contact
you. We feel that it is important that a customer does not have to log in to browse.
However, providing existing customers a way to authenticate themselves gives them the
ability to see past orders, and gives you the ability to tie behaviors together into a profile.
At present, the images for books have to be FTPed to the image directory and given the
correct name. You could add file upload to the book insertion page to make this easier.
You could add user login, personalization, and book recommendations; online reviews;
affiliate programs; stock level checking; and so on. The possibilities are endless.
Using an Existing System
If you want to get a highly featured shopping cart up and running quickly, you might want to
try using an existing shopping cart system. One well known Open Source cart implemented in
PHP is FishCartSQL, available from
http://www.fishcart.org/
Building Practical PHP and MySQL Projects
P
ART V
584
31 7842 CH25 3/6/01 3:39 PM Page 584