forked from ChamodLa/Examgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_tutor.php
116 lines (91 loc) · 4.04 KB
/
search_tutor.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
<?php
include 'components/connect.php';
if(isset($_COOKIE['user_id'])){
$user_id = $_COOKIE['user_id'];
}else{
$user_id = '';
header('Location: login.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- meta properties -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Search Tutors - ExamGIS</title>
<!-- Fav-icon -->
<link rel="apple-touch-icon" sizes="180x180" href="./images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./images/favicon/favicon-16x16.png">
<link rel="manifest" href="./images/site.webmanifest">
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<!-- custom css file link -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'components/user_header.php'; ?>
<section class="teachers">
<h1 class="heading">expert tutors</h1>
<form action="" method="post" class="search-tutor">
<input type="text" name="search_tutor" maxlength="100" placeholder="search tutor..." required>
<button type="submit" name="search_tutor_btn" class="fas fa-search"></button>
</form>
<div class="box-container">
<?php
if(isset($_POST['search_tutor']) or isset($_POST['search_tutor_btn'])){
$search_tutor = $_POST['search_tutor'];
$select_tutors = $conn->prepare("SELECT * FROM `tutors` WHERE name LIKE '%{$search_tutor}%'");
$select_tutors->execute();
if($select_tutors->rowCount() > 0){
while($fetch_tutor = $select_tutors->fetch(PDO::FETCH_ASSOC)){
$tutor_id = $fetch_tutor['id'];
$count_courses = $conn->prepare("SELECT * FROM `course` WHERE tutor_id = ?");
$count_courses->execute([$tutor_id]);
$total_courses = $count_courses->rowCount();
$count_papers = $conn->prepare("SELECT * FROM `paper` WHERE tutor_id = ?");
$count_papers->execute([$tutor_id]);
$total_papers = $count_papers->rowCount();
$count_likes = $conn->prepare("SELECT * FROM `likes` WHERE tutor_id = ?");
$count_likes->execute([$tutor_id]);
$total_likes = $count_likes->rowCount();
$count_comments = $conn->prepare("SELECT * FROM `comments` WHERE tutor_id = ?");
$count_comments->execute([$tutor_id]);
$total_comments = $count_comments->rowCount();
?>
<div class="box">
<div class="tutor">
<img src="uploaded_files/tutor_thumb/<?= $fetch_tutor['image']; ?>" alt="">
<div>
<h3><?= $fetch_tutor['name']; ?></h3>
<span><?= $fetch_tutor['profession']; ?></span>
</div>
</div>
<p>total courses : <span><?= $total_courses; ?></span></p>
<p>total papers : <span><?= $total_papers ?></span></p>
<p>total likes : <span><?= $total_likes ?></span></p>
<p>total comments : <span><?= $total_comments ?></span></p>
<form action="tutor_profile.php" method="post">
<input type="hidden" name="tutor_email" value="<?= $fetch_tutor['email']; ?>">
<input type="submit" value="view profile" name="tutor_fetch" class="inline-btn">
</form>
</div>
<?php
}
}else{
echo '<p class="empty">no results found!</p>';
}
}else{
echo '<p class="empty">please search something!</p>';
}
?>
</div>
</section>
<!-- teachers section ends -->
<!-- custom js file link -->
<script src="js/script.js"></script>
</body>
</html>