Back to DFS's Workshop Page
Back to Agenda Page


Processing Sports Information Problem

Getting Data from a File

For this problem, you are to cannibalize any available code and write a pair of scripts which can be run through the web browser.

From any one professional sports league which publishes its standings in subsets of teams, e.g., division, conference, etc., make available to the user at least two of the subsets. Check out these standings for

Store the data for each subset in its own file.

You will create two scripts, the first of which contains a form which is used to access the second.

  1. The main HTML or PHP page: sportfiles.html or sportfiles.php
    1. Introduce the program to the user
    2. Make the information for at least two of the subsets in a league available to the user by means of a select tag inside a form. The data should be in the following tab-separated format:
      #Name    GP  W  L  OTL
      Boston   14  8  3  3
      Buffalo  14  8  3  3
      Montreal 12  8  2  2
      Toronto  15  6  5  4
      Ottawa   14  6  6  2
      Using vi, create these files in the same directory as your scripts. Name your files with a .dat suffix. You may wish to use popen() (see also Accessing System Information) to create the select list.
    3. Send the selected file name to sportfiletable.php
  2. The second PHP page: sportfiletable.php
    For the set of data in the file whose name was sent from the form,
    1. Display the name of the league
    2. Display a table with all of the data from the file, plus the data that is calculated

Click here to see a solution to this problem.


© 2008 DFStermole
Created 9 Nov 08
Last Modified 11 Nov 08