-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
168 lines (134 loc) · 4.36 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
//page for search result
include('php/connect_db.php');
//including header bar
include('php/header.php');
?>
<html>
<!--- A MNgo Creation by: Aditya Suman (http://www.mngo.in/aditya.php)-->
<head>
<title>Search | Catchfreedeal</title>
<style type="text/css">
body,html
{
background-color: #f1f1f1;
}
</style>
</head>
<body>
<div class="page_content">
<!-----search deal result-------->
<h4 class="content_deal_h4" id="deal_h">Deals</h4>
<div class="search_deal_div"></div>
<br>
<!-----search coupon result-------->
<h4 class="content_deal_h4" id="coupon_h">Coupons</h4>
<div class="search_coupon_div"></div>
<br>
<!-----search service result-------->
<h4 class="content_deal_h4" id="service_h">Services</h4>
<div class="search_service_div"></div>
<div class="deals_div"></div>
<!----footer------>
<br><br><br><br><br><br><br><br><br><br><br>
<?php
include('php/footer.php');
?>
</div>
<!--scripts-------->
<script type="text/javascript">
search_value = "<?php echo $_GET['search_input'] ?>";
search_value_length = search_value.length;
if(search_value_length >= 3)
{
/*----searching deal by name------*/
query_to_send = "SELECT * FROM content_deal WHERE name LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/deal_viewer.php', {query_to_send : query_to_send}, function(e)
{
$('.search_deal_div').append(e);
/*----searching deal by provider------*/
query_to_send = "SELECT * FROM content_deal WHERE provider LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/deal_viewer.php', {query_to_send : query_to_send}, function(e)
{
$('.search_deal_div').append(e);
/*----searching deal by tags------*/
query_to_send = "SELECT * FROM content_deal WHERE tag LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/deal_viewer.php', {query_to_send : query_to_send}, function(e)
{
$('.search_deal_div').append(e);
searched_deal = $('.search_deal_div .content_div').length;
//alert(searched_deal);
if(searched_deal == 0)
{
$('.search_deal_div').fadeOut(0);
$('#deal_h').fadeOut(0);
}
else
{
$('.search_deal_div').fadeIn(0);
$('#deal_h').fadeIn(0);
}
});
});
});
/*----searching coupon by provider------*/
query_to_send = "SELECT * FROM content_coupon WHERE provider LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/coupon_viewer.php', {query_to_send : query_to_send}, function(e)
{
//alert(e);
$('.search_coupon_div').append(e);
searched_coupon= $('.search_coupon_div .content_coupon_div').length;
//alert(searched_coupon);
if(searched_coupon == 0)
{
$('.search_coupon_div').fadeOut(0);
$('#coupon_h').fadeOut(0);
}
else
{
$('.search_coupon_div').fadeIn(0);
$('#coupon_h').fadeIn(0);
}
});
/*----searching service by provider------*/
query_to_send = "SELECT * FROM content_service WHERE provider LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/service_viewer.php', {query_to_send : query_to_send}, function(e)
{
//alert(e);
$('.search_service_div').append(e);
/*----searching service by location------*/
query_to_send = "SELECT * FROM content_service WHERE location LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/service_viewer.php', {query_to_send : query_to_send}, function(e)
{
//alert(e);
$('.search_service_div').append(e);
/*----searching service by tag------*/
query_to_send = "SELECT * FROM content_service WHERE tag LIKE '%" + search_value + "%' ORDER BY id DESC LIMIT 15";
$.post('php/service_viewer.php', {query_to_send : query_to_send}, function(e)
{
//alert(e);
$('.search_service_div').append(e);
searched_service= $('.search_service_div .content_service_div').length;
//alert(searched_service);
if(searched_service == 0)
{
$('.search_service_div').fadeOut(0);
$('#service_h').fadeOut(0);
}
else
{
$('.search_service_div').fadeIn(0);
$('#service_h').fadeIn(0);
}
/*-------if no deal no service and not any coupon is found----------*/
if(searched_service ==0 && searched_deal ==0 && searched_coupon ==0)
{
$('.deals_div').html("sorry no such deals found at the moment").css('color', 'red');
}
});
});
});
}
</script>
</body>
</html>