tailieunhanh - PHP and MySQL Web Development - P136

PHP and MySQL Web Development - P136: 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 User Functions 647 Now that we know how this list is produced let s look at the action buttons associated with these displays. Viewing List Information The Information button shown in Figure triggers the information action which is as follows case information display_information HTTP_GET_VARS id break To see what the display_information function does look at Figure . Figure The display_information function shows a blurb about a mailing list. The function displays some general information about a particular mailing list as well as listing the number of subscribers and the number of newsletters that have been sent out to that list and are available in the archive more on that in a minute . The code for this function is shown in Listing . 648 Chapter 28 Building a Mailing List Manager Listing display_information Function from Displaying List Information function display_information listid if listid return false info load_list_info listid if info echo h2 .pretty info listname . h2 echo p .pretty info blurb p echo p Number of subscribers . info subscribers p echo p Number of messages in archive . info archive p The display_information function uses two other functions to help it achieve its Web task the load_list_info function and the pretty load_list_info function actually retrieves the data from the database. The pretty function simply formats the data from the database by stripping out slashes turning newlines into HTML line breaks and so on. Let s look briefly at the load_list_info function is in the function library. The code for it is shown in Listing . Listing load_list_info Function from Building an Array of List Information function load_list_info listid if listid return false if db_connect return false query select listname blurb from lists where listid listid result mysql_query query if result echo Cannot retrieve this list return false info .

TỪ KHÓA LIÊN QUAN