-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresult.php
73 lines (46 loc) · 1.5 KB
/
result.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<title>Result page</title>
<style type="text/css">
.results {margin-left:12%; margin-right:12%; margin-top:10px;}
</style>
</head>
<body bgcolor="#F5DEB3">
<form action="result.php" method="get">
<span><b>Write your Keyword:</b></span>
<input type="text" name="user_keyword" size="120"/>
<input type="submit" name="result" value="Search Now">
</form>
<a href="search.html"><button>Go Back</button></a>
<?php
mysql_connect("localhost","root","");
mysql_select_db("search");
if(isset($_GET['search'])){
$get_value = $_GET['user_query'];
if($get_value==''){
echo "<center><b>Please go back, and write something in the search box!</b></center>";
exit();
}
$result_query = "select * from sites where site_keywords like '%$get_value%'";
$run_result = mysql_query($result_query);
if(mysql_num_rows($run_result)<1){
echo "<center><b>Oops! sorry, nothing was found in the database!</b></center>";
exit();
}
while($row_result=mysql_fetch_array($run_result)){
$site_title=$row_result['site_title'];
$site_link=$row_result['site_link'];
$site_desc=$row_result['site_desc'];
$site_image=$row_result['site_image'];
echo "<div class='results'>
<h2>$site_title</h2>
<a href='$site_link' target='_blank'>$site_link</a>
<p align='justify'>$site_desc</p>
<img src='images/$site_image' width='100' height='100' />
</div>";
}
}
?>
</body>
</html>