-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_all_items_report.php
41 lines (31 loc) · 1.21 KB
/
list_all_items_report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/* ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); */
include('config.php');
include 'templates/header.php';
// Include the database connection file
require_once 'db.php';
$db = get_db_connection();
// Query to retrieve all items, including truck name and locker name, sorted by truck name and locker name
$report_query = $db->prepare("
SELECT
t.name as truck_name,
l.name as locker_name,
i.name as item_name
FROM items i
JOIN lockers l ON i.locker_id = l.id
JOIN trucks t ON t.id = l.truck_id
ORDER BY t.name, l.name;
");
$report_query->execute();
$report_data = $report_query->fetchAll(PDO::FETCH_ASSOC);
echo "<div class='truck-listing'>\n<table>\n\t<tr><th>Truck Name</th><th>Locker Name</th><th>Item Name</th></tr>\n";
foreach ($report_data as $item):
echo "\t<tr>\n\t\t<td>" . htmlspecialchars($item['truck_name']) . "</td>\n";
echo "\t\t<TD>" . htmlspecialchars($item['locker_name']) . "</td>\n";
echo "\t\t<TD>" . htmlspecialchars($item['item_name']) . "</td>\n\t</tr>\n";
endforeach;
echo "</table></div>\n";
include 'templates/footer.php';
?>