<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<title>Query Tester</title>
	</head>

	<body>

<?php
	# checks whether the given result was successful, and if not, prints an error
	function check($value, $other_info) {
		if (!$value) {
			die("SQL error in '$other_info': " . mysql_error());
		}
	}

	# connect to the database and ask it for all movies
	$db = mysql_connect("webster.cs.washington.edu",
	                    "jkmiller",
	                    "9v3nTBWiL2eBC")
	      || die('Could not connect: ' . mysql_error());
	check($db, "mysql_connect");
	check(mysql_select_db("imdb_small"), "mysql_select_db");

	$query = "SELECT *
	          FROM movies
	          WHERE year = 2000";
	$results = mysql_query($query);
	$row = mysql_fetch_array($results);

	print $query;

/*
	$title = 'Pi';
	$query = "SELECT year FROM movies WHERE name = $title";
	$results = mysql_query($query);

	#check($results, $query);

	# print the results



			<pre>
			<?php
			print_r($row);
			?>
			</pre>
*/
?>

		<?= $query ?>

		<ul>

<?php
while ($row = mysql_fetch_array($results)) {
?>
    	<li> <?= $row["name"] ?> </li>

<?php
}
?>

		</ul>

	</body>
</html>
