CSci 115: Computing and the Internet
Home Syllabus Assignments Tests

Assignment 5: Fora

Due at:9:40am, Thu 25 Oct
Point value:30 pts
Groupwork:You may work with one other student if you wish.

In class we have been working with the forum database for handling a forum. In fact, this database is configured so that it handles multiple fora.

To do this, the Posts table in the forum database contains a fifth column named forumid (in addition to the columns that we saw in class, named poster, postdate, title, and body). A third table, named Forums, contains just two columns, named forumid and title. The forumid column for each row of the Posts table corresponds to the forumid for a row in the Forums table. Thus, if you wanted to determine the name of the forum for a message, you would look at the post's forumid; then you would look through the Forums table to find a row with a matching forumid; this row would contain the forum's title.

Problem 1. First, create fora.php so that it lists the title of each forum in the database. This PHP script need only look at the Forums table, not the Posts or Users tables. Each forum's title should be linked to another PHP script via a URL such as the following.

(The number at the end would be the forumid for that forum.)

Problem 2. Now create posts.php, which lists all posts in the forum identified by the $form_id variable. (This $form_id variable will come from the URL when you click on a link in your solution to Problem 1.)

Feel free to copy and paste the PHP code we did in class to use as a starting point.

There are two possible ways of restricting the list only to the identified forum. One possibility is to change the SQL statement so it lists the forumid of each message, and then modify the PHP for loop so it displays only those messages with the proper ID. Do not do this. Instead, you should modify the SQL statement so it returns only those messages with the proper forumid. (This latter technique is more efficient, because it reduces the amount of information that the MySQL server has to send to the PHP script.)

Problem 3. Modify your solution from the previous problem so that it also displays the name of the forum as the page header. The resulting page should look like the following.

Note that this should work even when the forum contains no messages (as is the case with the forum named Test Forum).