tailieunhanh - PHP and MySQL Web Development - P147

PHP and MySQL Web Development - P147: 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. | 702 Chapter 29 Building Web Forums Listing Continued check not a duplicate query select from header body where and . post parent . and . post poster . and . post title . and . post area . and . post message . result mysql_query query if result return false if mysql_numrows result 0 return mysql_result result 0 0 query insert into header values . post parent . . post poster . . post title . 0 . post area . now NULL result mysql_query query if result return false note that our parent now has a child query update header set children 1 where postid . post parent result mysql_query query if result return false find our post id note that there could be multiple headers that are the same except for id and probably posted time query select from header left join body on where parent . post parent . Extensions 703 Listing Continued and poster . post poster . and title . post title . and is NULL result mysql_query query if result return false if mysql_numrows result 0 id mysql_result result 0 0 if id query insert into body values id . post message . result mysql_query query if result return false return id This is a long function but it is not overly complex. It is only long because inserting a posting means inserting entries in the header and body tables and updating the parent article s row in the header table to show that it now has children. That is the end of the code for the Web forum application. Extensions There are many extensions you could add to this project You could add navigation to the view options so that from a post you could navigate to the next message the previous message the next-in-thread message or the previous-in-thread message. You could add an administration interface for setting up new forums and deleting old posts. You could add user authentication so only registered users could .

TỪ KHÓA LIÊN QUAN