Project assignment 2. Due Tuesday April 11 at 10 pm
Displaying database data
For this project installment you need to display posts and comments
using the data stored in the database. The pages should be connected
to each other by links. Use the files for project assignment 1 as a
starting point, but rename the files (to keep the ones for the
previous assignment so that they can be graded). An even better
solution would be to copy the files into a separate directory, this
way you don't need to rename any files. Below are the details of this
- You need to write a php file displaying posts, another file
displaying comments, and another one displaying information about a
user (such as name, display name, and a link to the user's website, if
any). You may also have
a file with some sort of "front
page" of the blog, but this is optional. You may also create separate
files for functions and other code used by different files of the
program, such as database information (username, password, etc.),
database queries, etc.
- To display posts: the posts should be retrieved
from the database using the SELECT statement. If posts are added to
the database then reloading the page should show the change.
- Set a limit on how many posts you can display on a page. As an
extra credit, add a link "more" at the end of the page that will
display the next group of posts.
- Post titles should be links to the page with the post and its
comments. The text showing the number of comments to a post (for
instance, "5 comments") should link to the same page. The words
"Comment on it" for now may link to the same page since we don't yet
have forms for adding a comment.
- To display an individual post and comments:Use
the GET method to pass the parameter to this page which is the post
ID. Using the ID, select the post and its comments from the
- Just as with posts, set a limit on how many comments you can
display on a page.
To display user information: Clicking on user name
on any page should bring up the page that displays information about
that user. It's OK if the page doesn't have much information on
it. Use GET method to pass the user ID to the page.
- Add a link from the comments page to the page with all
- Database functions should handle errors in a reasonable way (see
- The database connection must be closed at the end. Make sure that
even if there is an error in accessing the data, the database
connection is still closed.
- Use CSS files to format the pages.
- The pages should generate XHTML-compliant code.
This page is a part of CSci 1101
course web site.
The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.