-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
45 lines (30 loc) · 1.13 KB
/
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
36
37
38
39
40
41
42
43
44
45
<?php
include('config.php');
if($_POST)
{
$conn = mysqli_connect('localhost','u414877475_cache','jaikumari@9821','u414877475_cache') or die(mysqli_error());
$database = mysqli_select_db($conn,'u414877475_cache') or die(mysqli_error());
$q=$_POST['search'];
$sql_res=mysqli_query($conn,"select id,title,content from home_content where title like '%$q%' or content like '%$q%' order by id LIMIT 5");
if ($sql_res->num_rows > 0) {
// output data of each row
while($row = $sql_res->fetch_assoc()) {
$id=$row['id'];
$username=$row['title'];
$content=$row['content'];
$email = substr($content, 0, 50);
$b_username='<strong>'.$q.'</strong>';
$b_email='<strong>'.$q.'</strong>';
$final_username = str_ireplace($q, $b_username, $username);
$final_email = str_ireplace($q, $b_email, $email);
?>
<a href="Users/cacheblog.php?id=<?php echo $id;?>"><div class="show" align="left">
<img src="author.PNG" style="width:50px; height:50px; float:left; margin-right:6px;" /><span class="name"><?php echo $final_username; ?></span> <br/><?php echo $final_email; ?><br/>
</div></a>
<?php
}
} else {
echo "0 results";
}
}
?>