Except where otherwise noted, the contents of this document are Copyright 2010 Marty Stepp and Jessica Miller.
created by Brian Le and Marty Stepp
This lab's purpose is to practice problems that are similar to those on the final exam.
Write JavaScript code so that when the page loads, every table in the page will become "zebra striped."
zebrastripe
that you can attach to the odd rows.)
before | after |
|
|
---|
Write the complete JavaScript code to fetch XML data about rectangles and display it on the current page.
rect.php
in the same directory as your code. When contacted with no parameters, it outputs a group of rectangles to draw on the page, such as:
<?xml version="1.0" encoding="UTF-8"?> <shapes> <rectangle x="10" y="40" width="100" height="30" color="FFFF00" /> <rectangle x="190" y="10" width="20" height="60" color="9000DD" /> <rectangle x="30" y="120" width="90" height="55" color="00BB88" /> </shapes>
div
of the right position/ size/ color. Add it to the div
with id
of rectanglearea
:
<body> ... <div id="rectanglearea"></div> ... </body>
Write a PHP file lookup.php
that looks up a name in a file and outputs a URL about the person.
name
. Assume that the parameter is always passed.
employees.txt
. Full name, username, and position are separated by tabs:
Morgan Doocy mdoocy Devourer of Souls!!!! Conner Q. Reilly con74 Director of Archives Marla Jeffries mjeff Lamination Tzar
http://www.awesomeco.com/PositionNameWithoutSpaces/userName
lookup.php?name=Conner+Q.+Reilly
produces the following output:
http://www.awesomeco.com/DirectorofArchives/con74
http://www.awesomeco.com/
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:
id | first_name | last_name | gender |
---|---|---|---|
433259 | William | Shatner | M |
797926 | Britney | Spears | F |
... |
id | name | year |
---|---|---|
112290 | Fight Club | 1999 |
209658 | Meet the Parents | 2000 |
... |
actor_id | movie_id | role |
---|---|---|
433259 | 313398 | Capt. James T. Kirk |
797926 | 342189 | Herself |
... |
(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.
display_last_names
that displays these two lists, as shown below:
<!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>
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>
print
/echo
statements. You do not need to check for MySQL errors.
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!