You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.4 KiB
102 lines
3.4 KiB
6 months ago
|
<?php
|
||
|
require 'db_connection.php';
|
||
|
|
||
|
// Handle search request
|
||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
$blood_type = $_POST['blood_type'];
|
||
|
$urgency = $_POST['urgency_level'];
|
||
|
|
||
|
$sql = "SELECT users.first_name, users.last_name, blood_donors.blood_type, blood_donors.availability
|
||
|
FROM blood_donors
|
||
|
JOIN users ON blood_donors.donor_id = users.id
|
||
|
WHERE blood_donors.blood_type = ?";
|
||
|
|
||
|
if ($urgency !== "") {
|
||
|
$sql .= " AND blood_donors.availability LIKE ?";
|
||
|
}
|
||
|
|
||
|
$stmt = $conn->prepare($sql);
|
||
|
if ($urgency !== "") {
|
||
|
$stmt->bind_param("ss", $blood_type, "%$urgency%");
|
||
|
} else {
|
||
|
$stmt->bind_param("s", $blood_type);
|
||
|
}
|
||
|
$stmt->execute();
|
||
|
$result = $stmt->get_result();
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>Search Blood Donors</title>
|
||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<?php include 'includes/header.php'; ?>
|
||
|
|
||
|
<div class="container mt-4">
|
||
|
<h2>Search for Blood Donors</h2>
|
||
|
|
||
|
<form method="POST" action="recipient_search.php">
|
||
|
<div class="mb-3">
|
||
|
<label for="blood_type" class="form-label">Blood Type</label>
|
||
|
<select name="blood_type" id="blood_type" class="form-select" required>
|
||
|
<option value="">Select Blood Type</option>
|
||
|
<option value="A+">A+</option>
|
||
|
<option value="A-">A-</option>
|
||
|
<option value="B+">B+</option>
|
||
|
<option value="B-">B-</option>
|
||
|
<option value="O+">O+</option>
|
||
|
<option value="O-">O-</option>
|
||
|
<option value="AB+">AB+</option>
|
||
|
<option value="AB-">AB-</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
|
||
|
<div class="mb-3">
|
||
|
<label for="urgency_level" class="form-label">Urgency Level</label>
|
||
|
<select name="urgency_level" id="urgency_level" class="form-select">
|
||
|
<option value="">Select Urgency Level</option>
|
||
|
<option value="Low">Low</option>
|
||
|
<option value="Medium">Medium</option>
|
||
|
<option value="High">High</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
|
||
|
<button type="submit" class="btn btn-primary">Search Donors</button>
|
||
|
</form>
|
||
|
|
||
|
<?php if (isset($result)): ?>
|
||
|
<h4 class="mt-4">Donors List</h4>
|
||
|
<table class="table table-bordered">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Name</th>
|
||
|
<th>Blood Type</th>
|
||
|
<th>Availability</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php while ($row = $result->fetch_assoc()): ?>
|
||
|
<tr>
|
||
|
<td><?php echo $row['first_name'] . ' ' . $row['last_name']; ?></td>
|
||
|
<td><?php echo $row['blood_type']; ?></td>
|
||
|
<td><?php echo $row['availability']; ?></td>
|
||
|
</tr>
|
||
|
<?php endwhile; ?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
|
||
|
<?php include 'includes/footer.php'; ?>
|
||
|
</body>
|
||
|
|
||
|
</html>
|