TAILIEUCHUNG - PHP and MySQL Web Development - P112

PHP and MySQL Web Development - P112: 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. | Implementing the Shopping Cart 527 to get the book information out of the database and display_book_details book to output the data in HTML. One thing to note here is that display_book_details looks for an image file for the book as images . If this file does not exist no image will be displayed. The remainder of the script sets up navigation. A normal user will have the choices Continue Shopping which will take her back to the category page and Add to Cart which will add the book to her shopping cart. If a user is logged in as an administrator she will get some different options which we ll look at in the section on administration. That completes the basics of the catalog system. Let s go ahead and look at the code for the shopping cart functionality. Implementing the Shopping Cart The shopping cart functionality all revolves around a session variable called cart. This is an associative array that has ISBNs as keys and quantities as values. For example if I add a single copy of this book to my shopping cart the array would contain 0672317842 1 That is one copy of the book with the ISBN we add items to the cart they will be added to the array. When we view the cart we will use the cart array to look up the full details of the items in the database. We also use two other session variables to control the display in the header that shows Total Items and Total variables are called items and total_price respectively. Using the Script Let s begin looking at how the shopping cart code is implemented by looking at the script. This is the script that displays the page we will visit if we click on any View Cart or Add to Cart links. If we call without any parameters we will get to see the contents of it. If we call it with an ISBN as parameter the item with that ISBN will be added to the cart. To understand this fully look first at Figure . In this case we have clicked the View Cart link when .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
41    188    5    23-12-2024
8    164    3    23-12-2024
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.