Fix + aggiunta tabella ordini per cliente

This commit is contained in:
2026-02-25 10:50:41 +01:00
parent 260365286a
commit 79b48c2dd8

View File

@@ -1,15 +1,15 @@
<?php
require_once "db.conf.php";
require_once "db_conf.php";
$customer_id = $_GET["customerid"];
$order_id = $_GET["orderid"];
$customer_id = $_GET["customerId"];
$order_id = $_GET["orderId"];
$sql = "";
if (isset($_GET["customerid"])) {
if (isset($_GET["customerId"])) {
$sql = "SELECT o.* FROM Orders o INNER JOIN Customers c ON o.CustomerID = c.CustomerID WHERE c.CustomerID = " . $customer_id . ";";
}
else if (isset($_GET["orderid"])) {
else if (isset($_GET["orderId"])) {
$sql = "SELECT p.*, od.quantity AS order_quantity FROM Orders o INNER JOIN OrderDetails od ON o.OrderID = od.OrderID INNER JOIN Products p ON od.ProductID = p.ProductID WHERE o.OrderID =" . $order_id . ";";
}
else {
@@ -26,6 +26,34 @@ $result = mysqli_query($conn, $sql);
<title>Northwind Clients</title>
</head>
<body>
<?php
if($result){
if(isset($_GET["customerId"])){
# Tabella Prodotti
echo "<h2>Ordini del cliente " . $customer_id . "</h2>";
echo "<table>";
echo "<tr>";
if (mysqli_num_rows($result) == 0) {
echo "<th>Il cliente ". $customer_id ." non ha ordini</th>";
}
else {
echo "<th>ID Ordine</th>";
}
echo "</tr>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['OrderID']."</td>" ;
echo "</tr>";
}
echo "</table>";
}
else if(isset($_GET["orderid"])){
echo "WIP";
}
else {
echo "ERROR: FANKYULO";
}
}
?>
</body>
</html>