-
Notifications
You must be signed in to change notification settings - Fork 2
/
livesearch.php
53 lines (42 loc) · 1.17 KB
/
livesearch.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
<?php
$conn= mysqli_connect('localhost','root','','cbs');
///write new query here
$q=$_GET["q"];
$result1=mysqli_query($conn,"SELECT coursename FROM course where coursename like '%$q%' ");
$result2=mysqli_query($conn,"SELECT username FROM user where username like '%$q%' ");
$result3=mysqli_query($conn,"SELECT roomname FROM classroom where roomname like '%$q%' ");
$rows=mysqli_num_rows($result1);
if ($rows> 0)
{
while($row = mysqli_fetch_assoc($result1))
{
echo "<p><a href='#' class='leftborder'><b>".$row['coursename']."</b></a></p>";
}
}
else
{
$rows1=mysqli_num_rows($result2);
if ($rows1> 0)
{
while($row = mysqli_fetch_assoc($result2))
{
echo "<p><a href='#' class='leftborder'><b>".$row['username']."</b></a></p>";
}
}
else
{
$rows2=mysqli_num_rows($result3);
if ($rows2> 0)
{
while($row = mysqli_fetch_assoc($result3))
{
echo "<p><a href='#' class='leftborder'><b>".$row['roomname']."</b></a></p>";
}
}
else
{
echo "No news found according to this search term";
}
}
}
?>