A6-PHP Connections

On This Page


Overview

During this assignment, you will:

  • Create an HTML page with a .php file extension
  • Connect to your project database using PHP
  • Make simple queries using PHP
  • Display the results of your query in your Web page
  • Document your code

Note to Mac Users: PHP does not seem to like Mac end of lines character ("\r"). So make sure you choose the option that uses the *nix end of line character ("\n") in your text editor before turning in an assignment. For instructions on settings for various text editors, see John Govsky's page: Text Editors for HTML and Script Editing

Preparation

If your HTML is rusty, you may want to review basic tags and tables before completing this assignment. Check the Links page for suggested tutorials on HTML.

Specifications

This assignment has several parts and you must complete all parts for full credit.

  1. First make sure you have completed the exercises from lesson 6 and have saved the files using the specified names exactly. Using the specified file names makes for easier grading.
  2. Write a PHP-enhanced HTML page and include the following in your page:
    1. Opening and closing HTML tags
    2. Opening and closing header tags
    3. Opening and closing title tags with your project's name enclosed
    4. Opening and closing body tags
    5. At least one opening and closing heading tags (h1-6) with your projects name enclosed
    6. A brief description of your projects purpose using appropriate tags
  3. The name of the page must be about.php.

    Using the specified name makes grading easier. After you turn in the assignment, you can change the name of the page for your final project.

  4. In your about.php page, query your project database using PHP and display the query data in an organised way on your web page, such as in an HTML table.

    Remember that we looked at two ways of mixing PHP and HTML. In lesson 6.1.1 you can see an example of adding PHP tags inside of HTML. In lesson 6.1.5, you can see an example of adding HTML tags to PHP print statements. This same technique works with any HTML tag including table tags.

    Also, make sure your database connection, selection and query commands are embedded in your about.php page rather than an included file.

  5. Use the included file includes/dbconvars.php for all database connections in your code.

    Even though you do not need to submit your dbconvars.php file, the instructor will use one to test your work. If you do not follow the dbconvars.php standard then the instructor will not be able to test your page and you will get a poor grade.

  6. Create a PHP comment at the top of your page formatted like the following:
    /**
        CIS-165PH  Asn 6
        about.php
        Purpose: Displays information about my project and
        displays queries from my project database.
    
        @author Ed Parrish
        @version 1.0 03/16/07
    */
    

    Remember that PHP comments must be enclosed within PHP tags. You will get no credit for this part of the assignment if you use HTML comments. For more information on documenting PHP code, see: How To Document PHP Code.

  7. Export (dump) your database as SQL statements to a text file using the technique we discussed in lesson 2.1.5. Name your file after your database name and add the extension .sql to the name (dbname.sql). For example, the artzy database export file would be named artzy.sql.

    Make sure that your dbname.sql file:

    1. Does not contain a SQL 'USE' or 'CREATE DATABASE' statement anywhere in the file
    2. Includes DROP TABLE IF EXISTS statements for all tables

    Note that phpMyAdmin supports all these behaviors if you select the correct export settings.

    Also, make sure you test your database export by reloading your file. You should reload it into another database, like test, to make sure there are no errors during the load. If you add any kind of constraints, then you may need to manually reorder the tables to load the data from the file.

  8. Zip your files and submit the zipped archive file to Blackboard as explained in the section of this document: What to Turn In.

    Note: Please do not turn in more than one *.sql file or I may grade using the wrong file.

Sample Operation

For an example page, click here.

Extra Credit

The following are worth extra credit points:

  1. Add images or other artistic touches to your web page. (0 to 2 points)

Make certain that your README.txt file lists any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Lesson Exercises

  • 2: All lesson exercises attempted and turned in
  • 1: Some lesson exercises completed and turned in
  • 0: No lesson exercises completed or turned in

Database Export

  • 4: Database loads from dbname.sql file with no errors or warnings
  • 2: Database loads from dbname.sql file but has errors or warnings, or 'drop table' code is missing
  • 0: Does not load or dbname.sql file not submitted

PHP Functionality

  • 4: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above) with particularly elegant solutions
  • 3: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • PHP may show one minor warning
  • 2: Has much of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • PHP may show 2-3 minor warnings
  • 1: Serious functional problems but shows some effort and understanding
    • Demonstrates few techniques from the lesson
    • Meets few of the of the specifications (see above)
    • Implementation seems very convoluted
    • PHP shows a major error or many warnings
  • 0: Does not execute

HTML Code

  • 8: Demonstrates mastery of HTML
    • Has extra features or demonstrates techniques beyond the assignment
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors in the HTML code (both opening and closing tags used)
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets many of the specifications (see above)
    • May have 1-2 minor HTML errors.
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets some of the specifications (see above)
    • May have 3-5 minor errors
  • 2: Serious problems but shows some effort and understanding
    • Demonstrates few techniques from the lesson
    • Meets few of the of the specifications (see above)
    • Has many errors
  • 0: No HTML file submitted or page does not display anything

PHP Documentation

  • 2: Code is well-documented
    • Name, date, and page description in page comment block
    • Follows format for page comment block
    • Proper use of whitespace and indenting
    • Files are correctly zipped
  • 1: Code has minor documentation errors
    • Has 1-2 documentation errors
  • 0: No apparent attempt at documentation

README.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Maximum Score: 22, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Create a single zip file with the following items in the specified folders for grading:

  1. README.txt file
  2. All the exercise files from Lesson 6
  3. about.php file
  4. dbname.sql file
  5. Any other file needed to make your page work and display properly, such as image or CSS files

Note: if you turn in a file with the wrong file name, you may receive no credit.

You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files except dbconvars.php. Your assignment must work as submitted when the instructor adds a dbconvars.php file into the includes subdirectory.

Home | WebCT | Announcements | Course info | Expectations | Schedule
Project | Help | FAQ's | HowTo's | Links
Last Updated: April 16 2009 @16:16:21