Commit e66055a4 authored by Sorrel Harriet's avatar Sorrel Harriet

Duplicate

parent a2fd5b3b
<?php
// initialise string variable for content HTML
$content = "<h1>Orders</h1>";
// fetch all transactions (orders) and group by customer id
$sql = "SELECT id, customer_id FROM transaction
ORDER BY customer_id";
$result = mysqli_query($link, $sql);
// check query returned a result
if ($result === false)
{
echo mysqli_error($link);
} else {
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0)
{
$content .= "<table border='1'>";
$content .= "<thead><tr><th>Order ID</th><th>Customer ID</th></tr></thead>";
$content .= "<tbody>";
// fetch each row in result set as an associative array
while ($row = mysqli_fetch_assoc($result)) {
$content .= "<tr>";
$content .= "<td><a href=\"?page=order&order_id=".$row['id']."\">".$row['id']."</a></td>";
$content .= "<td>".$row['customer_id']."</td>";
$content .= "</tr>";
}
$content .= "</tbody></table>";
} else {
$content .= "<p>There are no orders to display.</p>";
}
// free result set
mysqli_free_result($result);
}
// output the content HTML
echo $content;
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment