Project assignment 3. Due Tuesday, April 6 at 11:59pm
Displaying database data
For this project installment you need to display posts and comments
using the data stored in the database. Use your team database. I will
send you information by e-mail during the Spring break or shortly after.
Meanwhile, you can use the wordpress database.
Use the
1101readonly account to access it. Please do not use
your admin database account in your php code.
The pages should be connected
to each other by links. Copy the files from project assignment 2 into
a separate directory so that the old files can be graded. Below are
the details of this project assignment:
- You need to write a php file for displaying posts, another file for
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. In addition you should have
auxiliary php files with functions and other code used by different
files of the program, such as database information (username,
password, etc.), database queries, etc.. Make sure not to
duplicate code unnecessarily: use functions whenever possible.
- 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 feature, you may add a link "more" at the end of the page
that will
display the next group of posts. To get the maximum credit for this
part, make sure that there is no "more" link on the last page.
- 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 comments page as well. 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 (i.e. extended URLs) to pass the parameter to this page
which is the post
ID. Using the ID, select the post and its comments from the
database.
- 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.
Requirements
- Database functions should handle errors in a reasonable way (see
in-class example).
- 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.
- The code should be well organized and commented. Avoid redundancy
by using variables for frequently used strings and by using functions
for repeated actions.
- Extra features (if any) should be described in the submission e-mail.
- For a group of three: at least one of your extra features must include using additional fields or tables in the database. Use fields that are currently there (such as categories) or add your own (file names for user pictures or a field that allows/disallows comments, for instance). Describe the feature in your submission e-mail, explain the database usage.
This page is a part of CSci 1101
course web site.