Created
October 13, 2012 00:02
-
-
Save erinbush/3882422 to your computer and use it in GitHub Desktop.
Joining tables and combining results in a table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<p><h2>Details</h2></p> | |
<p>Details of all the executions by state with lat/long data.</p> | |
<p><table border='1' cellpadding='10'> | |
<tr><th>First Name</th><th>Last Name</th><th>Crime</th><th>State</th><th>Lat</th><th>Long</th></tr> | |
<?php | |
$result = mysql_query("SELECT * FROM executions INNER JOIN statelatlong ON executions.statelatlongid = statelatlong.id", $connection); | |
if (!$result) { | |
die("Database query failed: "); | |
} | |
/* Organize results of Query into a table */ | |
while($row = mysql_fetch_array($result)) { | |
// set up a row for each record | |
echo "<tr>"; | |
echo "<td>" . $row['first'] . "</td>"; | |
echo "<td>" . $row['last'] . "</td>"; | |
echo "<td>" . $row['crime']. "</td>"; | |
echo "<td>" . $row['state']. "</td>"; | |
echo "<td>" . $row['lat']. "</td>"; | |
echo "<td>" . $row['long']. "</td>"; | |
echo "</tr>"; | |
} | |
?> | |
</table></p> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment