How to do everything with PHP (phần 4)

Tham khảo tài liệu 'how to do everything with php (phần 4)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 134 How to Do Everything with PHP MySQL Now that you can find your way around a PHP script it s time to start writing your own. This chapter brings the basic PHP course taught over the last few chapters to a logical conclusion by attempting to use as many of the constructs and techniques taught over the previous pages to create a working application. This example is of necessity somewhat contrived but I hope you find it interesting. How to. Create a web-based shopping cart Read and display a product catalog from a text file Store item quantities in a session and perform calculations on them Understanding Requirements The application here is a web-based shopping cart that uses PHP s built-in sessionmanagement support to track the items selected for purchase by a user. Items are listed in a product catalog and the user has the ability to select custom quantities of each item using an HTML form. The selected items then appear in the user s cart with item subtotals automatically calculated from the quantity and unit price. Users can clear their carts of all selected items or selectively update the quantities to be purchased of each item the totals are recalculated automatically. The catalog itself is read from a text file this file contains a list of product IDs descriptions and unit prices. If all this seems somewhat daunting fear not it s pretty simple once you break it down. Retrieving Catalog Data Let s begin with the catalog file itself and examine the format in which catalog data is stored 101 AA batteries pack of 2 102 AA batteries pack of 4 103 Backpack black 104 Money belt with 6 compartments black 105 Haversack red 106 Swiss Army knife 6 blades including can opener and scissors 107 Duffel bag steel gray TEAM Line CHAPTER 7 Sample Application Session-Based Shopping Cart 135 This is fairly easy to understand each product is listed on a separate line with colons used to demarcate the product code or SKU its description .

Không thể tạo bản xem trước, hãy bấm tải xuống
1    20    1    29-03-2023
Đã 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.