-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_claimed_items.php
More file actions
35 lines (27 loc) · 828 Bytes
/
get_claimed_items.php
File metadata and controls
35 lines (27 loc) · 828 Bytes
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
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lost_found_db";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SQL query to get the latest claimed and approved items
$sql = "SELECT id_item, item_name, location_found, img1, other_details FROM reported_items
WHERE status = 'Claimed' AND remark = 'Approved'
ORDER BY report_date DESC, report_time DESC";
$result = $conn->query($sql);
$items = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$items[] = $row;
}
}
// Return the results as JSON
header('Content-Type: application/json');
echo json_encode($items);
$conn->close();
?>