Skip to content

Instantly share code, notes, and snippets.

Created Oct 13, 2012
What would you like to do?
Joining tables and combining results in a table.
<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>
$result = mysql_query("SELECT * FROM executions INNER JOIN statelatlong ON executions.statelatlongid =", $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>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment