Đang chuẩn bị liên kết để tải về tài liệu:
Phát triển web với PHP và MySQL - p 75

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Building Web Forums CHAPTER 29 715 Article list (different views) View an article reply Add a new article FIGURE 29.2 There are three main parts of the blah-blah forum system. A summary of the files in this application is shown in Table 29.1. TABLE 29.1 Name index.php Files in the Web Forum Application Type Application Description The main page users will see when they enter the site. Contains an expandable and collapsible list of all the articles on the site. Form used for posting new articles. Stores articles entered in the new_post.php form. Displays an individual post and a list of the replies to that post. Contains the treenode class, which we. | Figure 29.2 There are three main parts of the blah-blah forum system. A summary of the files in this application is shown in Table 29.1. Table 29.1 Files in the Web Forum Application Name Type Description index.php Application The main page users will see when they enter the site. Contains an expandable and collapsible list of all the articles on the site. new_post.php Application Form used for posting new articles. store_new_post.php Application Stores articles entered in the new_post.php form. view_post.php Application Displays an individual post and a list of the replies to that post. treenode_class.php Library Contains the treenode class which we will use to display the hierarchy of posts. include_fns.php Library Brings all the other function libraries for this application together the other Library-type files listed here . data_valid_fns.php Library Data validation functions. db_fns.php Library Database connectivity functions. discussion_fns.php Library Functions for dealing with storing and retrieving postings. output_fns.php Library Functions for outputing HTML. create_database.sql SQL SQL to set up the database required for this application. Let s go ahead and look at the implementation. 29 Building Web Forums Building Practical PHP and MySQL Projects 716 Part V Designing the Database There are a few attributes we ll need to store about each article posted to the forum the person who wrote it called the poster the title of the article when it was posted and the article body. We will therefore need a table of articles. We ll create a unique ID for each article called the postid. Each article needs to have some information about where it belongs in the hierarchy. We could store information about an article s children with the article. However each article can have many replies so this can lead to some problems in database construction. As each article can only be a reply to one other it is easier to store a reference to the parent article that is the article