CS200: Computer Science, Spring 2003
|
Notes: Friday 4 April 2003
Schedule
- Now: Problem Set 7.
- Tuesday, 8 April: College CS Program Applications Due
- Friday, 11 April, 11:00 am: Christopher Frost and Michael Peck, Pancakes, Puzzles and Polynomials: Cracking the Cracker Barrel Game. UVa Research and Design Symposium, Rotunda (Dome Room).
- Friday, 18 April: Exam 2 out
- Wednesday, 23 April: Exam 2 Due
- 28 April (9am): Problem Set 8 Due
Attached: Dream Code: Programming languages for quantum computers are now being written, The Economist, 3 April 2003. (Article in The Economist about Problem Sets 6 and 7.)
HTML/PHP/SQL Example View generated page: presidents.php3
<html> <head><title>Presidents of the United States</title></head> <body> <h1>Presidents of the United States</h1> <p> <? // connection information $hostName = "dbm1.itc.virginia.edu"; $userName = "dee2b"; $password = "quist"; // Not my real password! $dbName = "dee2b_presidents"; // make connection to database mysql_connect($hostName, $userName, $password) or exit("Unable to connect to host $hostName"); mysql_select_db($dbName) or exit("Database $dbName does not exist on $hostName"); // Run a SQL Query $result = mysql_query("SELECT lastname, firstname FROM presidents " . "WHERE college='William and Mary' ORDER BY lastname"); // Determine the number of rows $numrows = mysql_num_rows($result); $numcols = mysql_num_fields($result); // print the results print "<table border=0 cellpadding=5><tr>"; for ($k = 0; $k < $numcols; $k = $k + 1) { print "<th>" . mysql_field_name ($result, $k) . "</th>"; } print "</tr>"; for ($i = 0; $i < $numrows; $i++) // $i++ is short for $i = $i + 1 { for ($j = 0; $j < $numcols; $j++) { print "<td>" . mysql_result ($result, $i, $j) . "</td>"; } print "</tr>"; } print "</table>"; mysql_close(); // Close the database connection ?> <p><hr> <a href="mailto:evans@cs.virginia.edu"><em>evans@cs.virginia.edu</em></a> </body> </html>
|
cs200-staff@cs.virginia.edu Using these Materials |