-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
41 lines (32 loc) · 1.12 KB
/
search.php
File metadata and controls
41 lines (32 loc) · 1.12 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
<?php
$type = $_REQUEST['type'];
$input = $_REQUEST['q'];
$input = strtolower($input);
$input = explode(' ', $input);
error_reporting(E_ERROR | E_PARSE);
try{
include('config.php');
$mysqli = new mysqli($host, $username, $password, $dbname);
//$sql = "SELECT title,`url`,course_name,course_id FROM course_video OUTER JOIN course_details ON (course_video.course_id = course_details.course_id)";
$sql = "SELECT title,course_id FROM course_video;";
$result = mysqli_query($db, $sql);
foreach($result as $r){
$title = strtolower($r["title"]);
$course_id = $r["course_id"];
$url = "http://localhost/course_enroll.php?course_id=" . $course_id;
foreach($input as $word){
if(strpos($title, $word) !== false){
//echo "<a href=''>sucess</a>";
if(strlen($title) > 30)
$title = substr($title,0,30) . "...";
echo "<a href='$url'>$title</a>";
}
}
}
$mysqli->close();
}
catch (PDOException $error){
//echo "<script>alert(\"Failed \")</script>";
echo 'connect failed:'.$error->getMessage();
}
?>