Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My query page so far, where I define the queries. Next step: having the user define the queries.
<html>
<head>
<title>U.S. Citizen Claims Against Mexico to 1846: Case Listing</title>
</head>
<body>
<?php include("open_db.php");
echo "<h1>U.S. Citizen Claims Against Mexico to 1846: Listing</h1>
<p>Below you will find the listing of claims against Mexico, date in which the claims were filed, and total amounts of the initial claim and final verdict. You can click to edit the claims, or to add new ones--or at least will be able to, once I figure out the whole forms thing.</p>";
// get the records from the database
if ($result = $conn->query("SELECT * FROM claim JOIN claim_person ON claim.case_no = claim_person.FK_case_no JOIN person ON claim_person.FK_person_no = person.person_no ORDER BY case_no;"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table border='1' cellpadding='10'>";
// set table headers
echo "<tr><th></th><th>Case Number:</th><th>Name:</th><th>Final award:</th><th>Decision date:</th></tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td><a href='records.php?case_no=" . $row->case_no . "'>Edit</a></td>";
echo "<td>" . $row->case_no . "</td>";
echo "<td>" . $row->first_name .' '. $row->last_name . "</td>";
echo "<td>$" . $row->final_total . "</td>";
echo "<td>" . $row->decision_date . "</td>";
echo "</tr>";
}
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$conn->close();
?>
<a href="records.php">Add New Record</a>
</body>
</html>
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.