Source of showHeroes.php

<html>
<head>
<title>Show Heros</title>
</head>
<body>
<h1>Show Heros</h1>
<?
//make the database connection
$conn  = mysql_connect("localhost", "aharris", "my_password");
if ($conn) {
  print "It worked...";
} else {
  print "There was a problem";
} // end if

mysql_select_db("aharris_db", $conn);

//create a query
$sql = "SELECT * FROM hero";
$result = mysql_query($sql);

print "Result is $result";

print "<table border = 1>\n";

//get field names
print "<tr>\n";
while ($field = mysql_fetch_field($result)){
  print "  <th>$field->name</th>\n";
} // end while
print "</tr>\n\n";

//get row data as an associative array
while ($row = mysql_fetch_assoc($result)){
  print "<tr>\n";
  //look at each field
  foreach ($row as $col=>$val){
    print "  <td>$val</td>\n";
  } // end foreach
  print "</tr>\n\n";
}// end while

print "</table>\n";
?>
</body>
</html>