PHP and MySQL Web Development - P111

PHP and MySQL Web Development - P111: 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. | 522 Chapter 25 Building a Shopping Cart Listing Continued do_html_footer The script begins by including the file that includes all the function libraries for this application. After that we must begin a session. This will be required for the shopping cart functionality to work. Every page in the site will use the session. There are some calls to HTML output functions such as do_html_header and do_html_footer both contained in . We also have some code that checks if the user is logged in as an administrator and gives her some different navigation options if she is we ll return to this in the section on the administration functions. The most important part of this script is get categories out of database cat_array get_categories display as links to cat pages display_categories cat_array The functions get_categories and display_categories are in the function libraries and respectively. The function get_ categories returns an array of the categories in the system which we then pass to display_categories . Let s look at the code for get_categories . It is shown in Listing . Listing get_categories Function from Function That Retrieves a Category List from the Database function get_categories query database for a list of categories conn db_connect query select catid catname from categories result @mysql_query query if result return false num_cats @mysql_num_rows result if num_cats 0 return false result db_result_to_array result return result Implementing the Online Catalog 523 As you can see this function connects to the database and retrieves a list of all the category IDs and have written and used a function called db_result_to_array located in . This function is shown in Listing . It takes a MySQL result identifier and returns a numerically indexed array of rows where each row is an associative array. Listing db_result_to_array Function from .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
272    23    1    29-11-2024
24    20    1    29-11-2024
Đã 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.