-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
35 lines (29 loc) · 939 Bytes
/
search.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
<?php
require "pdo.php";
if(isset($_POST['searchVal'])){
$searchq = $_POST['searchVal'];
if (strlen($searchq) > 2){
$sql_search = '
SELECT `Last Name`,`First Name`,`Student ID`
FROM students14_15
WHERE `First Name` LIKE "%'.$searchq.'%"
or `Last Name` LIKE "%'.$searchq.'%"
or concat(`First Name`, " " , `Last Name`) LIKE "%'.$searchq.'%"
or concat(`Last Name`, " " , `First Name`) LIKE "%'.$searchq.'%"
';
$stmt_search = $pdo->query($sql_search);
$totalrows = $stmt_search->rowCount();
if($totalrows == 0){
$output = 'There was no search results!';
}else{
while ($result = $stmt_search->fetch(PDO::FETCH_ASSOC)) {
$Sname = $result['First Name'].' '.$result['Last Name'];
$Searchid = $result['Student ID'];
$black = $Searchid;
$output .= '<div id="searchname"><a id="searchlink" href="students.php?studentid='.$Searchid.'"><span></span><div> '.$Sname.' </div></a></div>';
}
}
}
echo $output;
}
?>