```php getConnection(); // Handle search and filters $search = $_GET['search'] ?? ''; $category = $_GET['category'] ?? ''; $status = $_GET['status'] ?? 'available'; // Build query with filters $query = "SELECT i.*, r.locationFound, r.timestamp as foundDate, sl.name as storageName FROM items i LEFT JOIN reports r ON i.reportID = r.reportID LEFT JOIN storage_locations sl ON i.storageLocationID = sl.locationID WHERE 1=1"; $params = []; if ($search) { $query .= " AND (i.description LIKE :search OR i.category LIKE :search)"; $params[':search'] = "%$search%"; } if ($category) { $query .= " AND i.category = :category"; $params[':category'] = $category; } if ($status) { $query .= " AND i.status = :status"; $params[':status'] = $status; } $query .= " ORDER BY i.createdAt DESC"; $stmt = $connection->prepare($query); foreach ($params as $key => $value) { $stmt->bindValue($key, $value); } $stmt->execute(); $items = $stmt->fetchAll(PDO::FETCH_ASSOC); // Get categories for filter $categoriesQuery = "SELECT DISTINCT category FROM items WHERE category IS NOT NULL"; $categoriesStmt = $connection->prepare($categoriesQuery); $categoriesStmt->execute(); $categories = $categoriesStmt->fetchAll(PDO::FETCH_COLUMN); // Handle claim submission if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['claim_item'])) { if (!isLoggedIn() || !isOwner()) { header("Location: login.php"); exit(); } $itemID = $_POST['itemID']; $userId = $_SESSION['user_id']; // Check if item exists and is available $checkQuery = "SELECT * FROM items WHERE itemID = :itemID AND status = 'available'"; $checkStmt = $connection->prepare($checkQuery); $checkStmt->bindParam(':itemID', $itemID); $checkStmt->execute(); if ($checkStmt->rowCount() > 0) { // Handle proof upload $proofPath = null; if (isset($_FILES['proof']) && $_FILES['proof']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'uploads/proofs/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $fileExtension = pathinfo($_FILES['proof']['name'], PATHINFO_EXTENSION); $fileName = uniqid() . '.' . $fileExtension; $targetPath = $uploadDir . $fileName; if (move_uploaded_file($_FILES['proof']['tmp_name'], $targetPath)) { $proofPath = $targetPath; } } // Create claim $claimQuery = "INSERT INTO claims (itemID, ownerUserId, proofPath) VALUES (:itemID, :userId, :proofPath)"; $claimStmt = $connection->prepare($claimQuery); $claimStmt->bindParam(':itemID', $itemID); $claimStmt->bindParam(':userId', $userId); $claimStmt->bindParam(':proofPath', $proofPath); if ($claimStmt->execute()) { // Update item status $updateQuery = "UPDATE items SET status = 'claimed' WHERE itemID = :itemID"; $updateStmt = $connection->prepare($updateQuery); $updateStmt->bindParam(':itemID', $itemID); $updateStmt->execute(); $success = "Claim submitted successfully! We'll review your claim and contact you soon."; } } else { $error = "Item not available for claiming."; } } // Get specific item details if requested $itemDetail = null; if (isset($_GET['item'])) { $itemQuery = "SELECT i.*, r.*, sl.name as storageName, sl.address as storageAddress FROM items i LEFT JOIN reports r ON i.reportID = r.reportID LEFT JOIN storage_locations sl ON i.storageLocationID = sl.locationID WHERE i.itemID = :itemID"; $itemStmt = $connection->prepare($itemQuery); $itemStmt->bindParam(':itemID', $_GET['item']); $itemStmt->execute(); $itemDetail = $itemStmt->fetch(PDO::FETCH_ASSOC); } ?> Browse Items - Lost & Found
← Back to Browse
<?php echo $itemDetail['description']; ?>
No Image Available

Description:

Found Location:

Found Date:

Status:

Storage Location:

Storage Address:

Claim This Item

Photos, receipts, or documents that prove this item belongs to you

You need to login as an owner to claim this item.

Browse Found Items

<?php echo $item['description']; ?>
No Image

...

Found:

View Details

No items found matching your criteria.

```