-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
127 lines (119 loc) · 5.09 KB
/
home.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
$i = 0;
require_once 'php/DBConnect.php';
$db = new DBConnect();
$db->auth();
// Search by Blood Group
if (isset($_POST['searchBtn'])) {
$bloodGroup = $_POST['blood_group'];
$donors = $db->searchDonorWithBloodGroup($bloodGroup);
}
//Search By City
if (isset($_POST['searchByCityBtn'])) {
$city = $_POST['city'];
$donors = $db->searchDonorByCity($city);
}
$title = "Home";
$setHomeActive = "active";
include 'layout/header.php';
include 'layout/navbar.php';
?>
<div class="container">
<div class="row">
<div class="col-md-12">
<div style="padding-top:15px;" class="form-group col-md-12">
<form class="form-inline" role='form' method="post" action="home.php">
<div class="form-group">
<label class="form-label">Search for donor with blood group </label>
<div class="col-auto">
<select name="blood_group" class="form-control">
<option value="O+">O+</option>
<option value="O-">O-</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
</select>
</div>
<div class="col-auto">
<button class="btn btn-outline-secondary" name="searchBtn" >Search</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-12">
<div style="padding-top:15px;" class="form-group col-md-12">
<form class="form-inline" role='form' method="post" action="home.php">
<div class="form-group">
<label class="form-label">Search donor by city </label>
<div class="col-auto">
<input type="text" name="city" value="" required="true" class="form-control"/>
</div>
<div class="col-auto">
<button class="btn btn-outline-secondary" name="searchByCityBtn" >Search</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-3"></div>
</div>
<div class="jumbotron">
<div class="col-md-1">
</div>
<div class="col-md-10">
<!-- If the donor is searched by a particular blood group -->
<?php if(isset($_POST['searchBtn'])): ?>
<?php if(isset($donors[0])): ?>
<h3>
<label>Total Blood Units Available for <?= $donors[0]['b_type']; ?>:</label> <span class="emphasize"><?= count($donors); ?> Unit</span>
</h3>
<?php endif; ?>
<?php endif; ?>
<!-- If the donor is search by a particular City -->
<?php if(isset($_POST['searchByCityBtn'])): ?>
<?php if(isset($donors[0])): ?>
<label>Total Number of Donors in this City:</label> <span class="emphasize"><?= count($donors); ?></span>
<?php endif; ?>
<?php endif; ?>
<!-- if result has been fetched succesffully -->
<?php if (isset($donors)): ?>
<table class="table table-condensed">
<tr>
<th>Index</th>
<th>Name</th>
<th>Gender</th>
<th>Address</th>
<th>City</th>
<th>Mobile</th>
<th>Phone</th>
<th>Blood Group</th>
<tr>
<?php foreach ($donors as $d): $i++; ?>
<tr class="<?php
if ($i % 2 == 0) {
echo "bg-success";
} else {
echo "bg-danger";
}
?>" >
<td><?= $i; ?></td>
<td><a href="profile.php?id=<?= $d['id']; ?>"><?= $d['fname'] . " " . $d['mname'] . " " . $d['lname']; ?></a></td>
<td><?= $d['sex']; ?></td>
<td><?= wordwrap($d['h_address'], 20, "<br>"); ?></td>
<td><?= $d['city']; ?></td>
<td><?= $d['mobile']; ?></td>
<td><?= $d['phone']; ?></td>
<td><?= $d['b_type']; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<div class="col-md-1"></div>
</div>
</div>
<?php include 'layout/footer.php'; ?>