-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchStudentProcess.php
76 lines (70 loc) · 3.14 KB
/
searchStudentProcess.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
<?php
require "connection.php";
$stname = $_POST["stname"];
$grade = $_POST["grade"];
$query = "SELECT * FROM `student` INNER JOIN `classroom` ON
student.email=classroom.student_email INNER JOIN `grade` ON
classroom.grade_id=grade.id";
if (!empty($stname) & $grade == 0) {
$query .= " WHERE `first_name` LIKE '" . $stname . "%' OR `last_name` LIKE '" . $stname . "%'";
} else if (empty($stname) & $grade != 0) {
$query .= " WHERE `classroom`.`grade_id`='" . $grade . "'";
} else if (!empty($stname) & $grade != 0) {
$query .= " WHERE `first_name` LIKE '" . $stname . "%' OR `last_name` LIKE '" . $stname . "%' AND `classroom`.`grade_id`='" . $grade . "'";
}
$studentResultset = Database::search($query);
$studentRownumber = $studentResultset->num_rows;
if ($studentRownumber > 0) {
for ($x = 0; $x < $studentRownumber; $x++) {
$studentData = $studentResultset->fetch_assoc();
?>
<!-- Student card -->
<div class="col-12 p-2">
<div class="col-12 p-3 def-card bg-white">
<div class="row">
<div class="col-12 col-lg-2 my-auto">
<span><?php echo ($studentData["first_name"] . " " . $studentData["last_name"]); ?></span>
</div>
<div class="col-12 col-lg-3 my-auto">
<span><?php echo ($studentData["email"]); ?></span>
</div>
<div class="col-12 col-lg-1 my-auto">
<span><?php echo ($studentData["name"]); ?></span>
</div>
<div class="col-12 col-lg-3 d-grid mt-2 mt-lg-0">
<select class="def-input bg-body" id="upgrade-class">
<option value="0">Update Class To...</option>
<?php
$classResultset = Database::search("SELECT * FROM `grade`");
$classRownumber = $classResultset->num_rows;
for ($c = 0; $c < $classRownumber; $c++) {
$classData = $classResultset->fetch_assoc();
?>
<option value="<?php echo ($classData["id"]) ?>"><?php echo ($classData["name"]); ?></option>
<?php
}
?>
</select>
</div>
<div class="col-12 col-lg-3 d-grid mt-2 mt-lg-0">
<button class="def-btn def-btn-success text-white" onclick="upgradeClass('<?php echo ($studentData['email']); ?>');"><i class="bi bi-caret-up-fill text-white fs-6"></i> Update</button>
</div>
</div>
</div>
</div>
<!-- Student card -->
<?php
}
?>
<?php
} else {
?>
<!-- Student empty card -->
<div class="col-12 p-2">
<div class="col-12 pt-5 pb-5 def-card bg-white text-center">
<span>No Results</span>
</div>
</div>
<!-- Student empty card -->
<?php
}