Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PHP and MySQL Web Development - P117: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 552 Chapter 25 Building a Shopping Cart Listing 25.19 Continued tr td Description td td textarea rows 3 cols 50 name description php echo edit book description textarea td tr tr td php if edit echo colspan 2 align center php if edit we need the old isbn to find book in database if the isbn is being updated echo input type hidden name oldisbn value . book isbn . input type submit value php echo edit Update Add Book form td php if edit echo td echo form method post action delete_book.php echo input type hidden name isbn value . book isbn . echo input type submit value Delete book echo form td td tr table form php 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 php echo edit book price We even get a different submit button. In fact for the edit form we get two one 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. Using an Existing System 553 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 wouldn t know what category they were in and we would have no way of navigating to them That s the overview of the administration interface. For more details refer to the code it s all on the CD-ROM. Extending the Project We have built a fairly simple shopping cart system. There are many additions and enhancements we could make In a real online store you would need to build some kind of order tracking and fulfillment system at the moment there s no way to see the orders that have .