-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_transactions.php
41 lines (38 loc) · 1.42 KB
/
fetch_transactions.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
include 'conn.php';
$itemId = $_GET['item_id'] ?? null;
if ($itemId) {
$sql = "SELECT transaction_id, transaction_type, quantity, date_time, description FROM inventory_transactions WHERE item_id = ? ORDER BY date_time DESC";
$stmt = $conn->prepare($sql);
$stmt->execute([$itemId]);
$transactions = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($transactions)) {
echo '<table class="table table-bordered">';
echo '<thead>';
echo '<tr>';
echo '<th>Transaction ID</th>';
echo '<th>Type</th>';
echo '<th>Quantity</th>';
echo '<th>Date & Time</th>';
echo '<th>Description</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ($transactions as $transaction) {
echo '<tr>';
echo '<td>' . htmlspecialchars($transaction['transaction_id']) . '</td>';
echo '<td>' . htmlspecialchars(ucfirst($transaction['transaction_type'])) . '</td>';
echo '<td>' . htmlspecialchars($transaction['quantity']) . '</td>';
echo '<td>' . htmlspecialchars($transaction['date_time']) . '</td>';
echo '<td>' . htmlspecialchars($transaction['description']) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
} else {
echo '<p>No transactions found for this item.</p>';
}
} else {
echo '<p>Invalid item ID.</p>';
}
?>