MIS 4372 -- Midterm Answers-- Spring 2016 -- Parks

A table named websites was created with 202 rows using the the top 200 websites (from:https://gtmetrix.com/top1000.html) and google.com and youtube.com. The websites table specification is:

table name: websites columns:

  1. url varchar(60),
  2. pagespeed int,
  3. yslow int,
  4. totaltime int,
  5. totalelements int,
  6. totalsize int
The column url contains the complete URL of the each website. The remaining five columns are gtmetrix.com's five performance measures for websites (all stored as integers):
  1. pagespeed: Google's Page Speed (0 → 100, 100 is best)
  2. yslow: Yahoo's YSLOW metric (0 → 100, 100 is best)
  3. totaltime: Total page load time
  4. totalelements: Total number of HTML elements
  5. totalsize: Total page size (measured in kilobytes)

  1. (50 points) Write the asp program with two passes for a INSERT program (named add_website.asp) that allows a user to add a row to the websites table. Specifically:

    1. the first pass (named pass1) contains:

      1. a form with action="add_website.asp" and method="POST"
      2. include 6 clearly labeled textboxes (you pick their design) to record the six values for the six columns in the table websites
      3. a hidden variable with name="token" with a value of "2"
      4. a submit button

    2. the second pass (named pass2) receives the data from the first pass and then:

      1. performs an existence test on the websites table to see if URL already exists in the table.
      2. if the step above shows that the URL is already in the table, write the message that says: "URL already in the table"
      3. if the step above shows that the URL is NOT in the websites table: INSERT the appropriate new row (with six values) into the websites table. If the INSERT works, return a message to the user that says: "INSERT OK" otherwise return "INSERT FAILED".

    Do not write the "main". Do not edit the data in pass1. Do not use parameters or transaction control in pass2.
     
  2. (50 points) Write an asp program named "show_websites.asp" to display the entire websites table in an HTML table. This asp program is used as the action in an HTML page as shown below:

    <form name="fred" action="http://.........show_websites.asp" METHOD="POST">
    Pick A Performance Measure or the URL:
    <input type="radio" name="c" value="0"> URL
    <input type="radio" name="c" value="1"> Page Speed
    <input type="radio" name="c" value="2"> YSLOW
    <input type="radio" name="c" value="3"> Load Time
    <input type="radio" name="c" value="4"> Elements
    <input type="radio" name="c" value="5"> Size
    
    Sort Order: <input type="radio" name="ad" value="ASC"> Ascending <input type="radio" name="ad" value="DESC"> Descending <input type="submit"> </form>

    The HTML table produced by show_websites.asp should show the following data:

    • a row number in column 1
    • each website's URL in column 2
    • the five performance columns in columns 3 through 7

    The table should be sorted using the column chosen (one of six) by the HTML page shown above. Additionally use the radio named ad to further describe the sort order. Write only the code for show_websites.asp (NOTE: it is a single pass program, there is NO "main" code). Do NOT use parameters or transaction control. Show no heading row.

NOTE: In both problems above, use the following values for the database credentials (database, userid, and password): gl001; gl001; and 11111.