Skip to content

Instantly share code, notes, and snippets.

@erinbush erinbush/joindisplay
Created Oct 13, 2012

Embed
What would you like to do?
Joining tables and combining results in a table.
<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
You can’t perform that action at this time.