Đang chuẩn bị liên kết để tải về tài liệu:
PHP and MySQL Web Development - P146
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PHP and MySQL Web Development - P146: 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. | Adding New Articles 697 Figure 29.8 Replies have the text of the original automatically inserted and marked. Listing 29.8 new_post.php Allows a User to Type a New Post or Reply to an Existing Post php include include_fns.php title HTTP_POST_VARS title poster HTTP_POST_VARS poster message HTTP_POST_VARS message if isset HTTP_GET_VARS parent parent HTTP_GET_VARS parent else parent HTTP_POST_VARS parent if area area 1 if error if parent 698 Chapter 29 Building Web Forums Listing 29.8 Continued parent 0 if title title New Post else get post name title get_post_title parent append Re if strstr title Re false title Re . title make sure title will still fit in db title substr title 0 20 prepend a quoting pattern to the post you are replying to message add_quoting get_post_message parent do_html_header title display_new_post_form parent area title message poster if error echo Your message was not stored. Make sure you have filled in all fields and try again. do_html_footer After some initial setting up this script checks whether the parent is zero or otherwise. If it is zero this is a new topic and little further work is needed. If this is a reply parent is the postid of an existing article then the script goes ahead and sets up the title and the text of the original message as follows get post name title get_post_title parent append Re if strstr title Re false title Re . title Adding New Articles 699 make sure title will still fit in db title substr title 0 20 prepend a quoting pattern to the post you are replying to message add_quoting get_post_message parent The functions it uses here are get_post_title get_post_message and add_quot-ing . These functions are all from the discussion_fns.php library. They are shown in Listings 29.9 29.10 and 29.11 respectively. Listing 29.9 get_post_title Function from discussion_fns.php Retrieves a Message s Title from the Database function get_post_title postid extract one post s name from the database if postid return conn db_connect .