University of Washington, CSE 190 M

Lab 9: Practice Final Exam Problems

Except where otherwise noted, the contents of this document are Copyright 2010 Marty Stepp and Jessica Miller.

created by Brian Le and Marty Stepp

Valid XHTML 1.1 Valid CSS!

Basic lab instructions

This lab's purpose is to practice problems that are similar to those on the final exam.

Exercise : JavaScript/DOM/Prototype

Write JavaScript code so that when the page loads, every table in the page will become "zebra striped."

beforeafter
NameBounces
Snuggles7
Horseface13
Cornelius3
Tigger1000
NameFavorite Pasta
SnugglesFettucini Alfredo
HorsefaceSpaghetti Pomodoro
CorneliusChicken Penne
NameBounces
Snuggles7
Horseface13
Cornelius3
Tigger1000
NameFavorite Pasta
SnugglesFettucini Alfredo
HorsefaceSpaghetti Pomodoro
CorneliusChicken Penne

Exercise : Ajax/XML

Write the complete JavaScript code to fetch XML data about rectangles and display it on the current page.

Exercise : PHP

Write a PHP file lookup.php that looks up a name in a file and outputs a URL about the person.

Exercise : SQL

Write an SQL query to show all actors who share the same last name and were in a movie together. Display the first names, last name, and movie name. Do not match up an actor with him/herself. Order by last name.

+-----------------+------------+-----------+---------------------+
| first_name      | first_name | last_name | name                |
+-----------------+------------+-----------+---------------------+
| Bill (I)        | Frankie J. | Allison   | Ocean's Eleven      | 
| Anthony         | Frankie J. | Allison   | Ocean's Eleven      | 
| Anthony         | Bill (I)   | Allison   | Ocean's Eleven      | 
| J. Todd         | Sharon     | Anderson  | Fargo               | 
| ...             | ...        | ...       | ...                 |
| Elenor          | Rowan      | Witt      | Matrix, The         | 
| Ben (I)         | Samuel E.  | Wright    | Little Mermaid, The | 
+-----------------+------------+-----------+---------------------+   134 rows in set

Recall that the imdb database contains the following tables:

actors
idfirst_namelast_namegender
433259WilliamShatnerM
797926BritneySpearsF
...
movies
idnameyear
112290Fight Club1999
209658Meet the Parents2000
...
roles
actor_idmovie_idrole
433259313398Capt. James T. Kirk
797926342189Herself
...

Exercise : PHP, HTML, SQL

(The next 2 slides describe this exercise. Please read them both, then start.)

Write the PHP code to display all the results from the preceding SQL query in two ordered lists.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
    ...
    <body>
        <?php
        display_last_names();
        ?>
    </body>
</html>

Exercise , continued

Your code should produce the following output (abbreviated):

<ol>
    <li>Allison, Anthony / Bill (I): Ocean's Eleven</li>
    <li>Allison, Anthony / Frankie J.: Ocean's Eleven</li>
    <li>Allison, Bill (I) / Frankie J.: Ocean's Eleven</li>
    <li>Anderson, George (IV) / Jo (I): JFK</li>
    ...
    <li>Jones, Annette / James Earl: Star Wars</li>
    <li>Jones, Annette / Linda (I): Star Wars</li>
    <li>Jones, James Earl / Linda (I): Star Wars</li>
</ol>
<ol>
    <li>Kennedy, Caroline / Ethel (II): JFK</li>
    <li>Kennedy, Caroline / Jacqueline (I): JFK</li>
    ...
    <li>Witt, Elenor / Rowan: Matrix, The</li>
    <li>Wright, Ben (I) / Samuel E.: Little Mermaid, The</li>
</ol>
  • You may have to give unique names to columns in your query, so you can access the columns in your PHP code. Do not use print/echo statements. You do not need to check for MySQL errors.

If you finish them all...

If you finish all the exercises, you're done! You could go look at the recent section practice final exam problems, or if the lab is over or almost over, check with a TA and you may be able to be dismissed.

Great work! Good luck on the final exam!