-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_projects.php
More file actions
134 lines (119 loc) · 5.04 KB
/
fetch_projects.php
File metadata and controls
134 lines (119 loc) · 5.04 KB
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
128
129
130
131
132
133
134
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mini_project";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get the search query from the URL
$search_query = isset($_GET['query']) ? $_GET['query'] : '';
// Prepare the SQL query to search in the relevant fields
$sql = "SELECT project_id, project_title, academic_year, project_mentor
FROM project_details
WHERE project_id LIKE ?
OR project_title LIKE ?
OR project_mentor LIKE ?
OR academic_year LIKE ?
OR student_1 LIKE ? OR usn_1 LIKE ?
OR student_2 LIKE ? OR usn_2 LIKE ?
OR student_3 LIKE ? OR usn_3 LIKE ?
OR student_4 LIKE ? OR usn_4 LIKE ?
OR student_5 LIKE ? OR usn_5 LIKE ?";
// Prepare and bind the parameters
$stmt = $conn->prepare($sql);
$search_param = "%$search_query%";
$stmt->bind_param('ssssssssssssss', $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param, $search_param);
// Execute the statement
$stmt->execute();
$result = $stmt->get_result();
// Fetch and display the results
$rows = '';
while ($row = $result->fetch_assoc()) {
$rows .= "<tr>";
$rows .= "<td>" . htmlspecialchars($row['project_id']) . "</td>";
$rows .= "<td>" . htmlspecialchars($row['project_title']) . "</td>";
$rows .= "<td>" . htmlspecialchars($row['academic_year']) . "</td>";
$rows .= "<td>" . htmlspecialchars($row['project_mentor']) . "</td>";
$rows .= "<td><a href='6-project_details.html?id=" . htmlspecialchars($row['project_id']) . "' class='btn'>Click Here</a></td>";
$rows .= "</tr>";
}
// Close connection
$stmt->close();
$conn->close();
// Output the entire HTML content
echo "
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<link rel='stylesheet' href='5-project_list.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css'>
<link rel='stylesheet'
href='https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200' />
<title>Search Results</title>
</head>
<body>
<div class='container'>
<nav>
<ul>
<li><a href='#' class='logo'>
<img id='im' src='profile.png' alt=''>
<span class='nav-head'>Student Project Management System</span>
</a></li>
<li><a href='2-dashboard.html'>
<!-- <i class='fas fa-home'></i> -->
<img class='nav-icon' src='Home-button.png' alt='Home'>
<span class='nav-item'>Home</span>
</a></li>
<li><a href='#' id='return-link'>
<img class='nav-icon' src='Return-button.png' alt='Return'>
<!-- <i class='fas fa-arrow-left'></i> -->
<span class='nav-item'>Return</span></a></li>
<li><a href='#'>
<img class='nav-icon' src='Help-button.png' alt='help'>
<!-- <i class='fas fa-question-circle'></i> -->
<span class='nav-item'>Help</span></a></li>
<li><a href='1-index.html' class='logout'>
<img class='nav-icon' src='Log-out-button.png' alt='Logout'>
<!-- <i class='fas fa-sign-out-alt'></i> -->
<span class='nav-item'>Logout</span></a></li>
</ul>
</nav>
<section class='main'>
<div class='search-container'>
<form action='fetch_projects.php' id='bhu' method='GET'>
<div class='search'>
<span><img src='Search_Icon.png' class='nav-icon2' alt='error'></span>
<input type='search' name='query' class='search-input' placeholder='Search' value='" . htmlspecialchars($search_query) . "'>
</div>
</form>
</div>
<div class='project-container'>
<table>
<thead>
<tr>
<th>Project ID</th>
<th>Project Title</th>
<th>Academic Year</th>
<th>Project Mentor</th>
<th>Action</th>
</tr>
</thead>
<tbody id='project-list'>
$rows
</tbody>
</table>
</div>
</section>
</div>
</body>
<script>
document.getElementById('return-link').addEventListener('click', function(event){event.preventDefault();window.history.back();});
</script>
</html>";
?>