IS 337: Website Administration

Assignment 10: Exponentiation Table with a Form

The Table

Create a PHP document that generates an exponentiation table.

0 1 2 3
1 1 1 1 1
2 1 2 4 8
3 1 3 9 27

PHP does not have an exponentiation operator; it does have a pow() function, but you can't use it ('cause I said so!). Instead, write your own function (a real PHP function).

Format the table nicely (e.g., numbers should be right aligned). (No, my table is not formatted nicely.)

Your webpage must validate (using the validator at the W3C).

Use a form to collect the size of the table (the table above has size 3).

Alternate colors on the rows of the table.

The page should have three different reactions:

  • If the page is accessed without any parameters sent, display only the form.
  • If the page is accessed with invalid parameters, display only the form with an error message that the input was bad. (Check out PHP functions is_int() and is_numeric(); one of these is better than the other.)
  • If the page is accessed with valid parameters, display the appropriate multiplication table. Include a link to the same page so that the use can easily get to the form.

Submit

Publish on webpub/yardley. Submit a URL to the first page as Assignment 10 on KnightVision.

Creative © 2007 Calvin College and Jeremy D. Frens.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.