-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
93 lines (64 loc) · 1.37 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
<?php
$query = $_POST["flag1"];
$rs = "";
$category = 0;
$category = $_POST["flag2"];
$constraint = $_POST["flag3"];
include "db.php";
$temp = explode(" ",$query);
$altdata = "kd";
function checkintruder($query)
{
if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $query) || $query=="")
{
return false;
}
else
{
return true;
}
}
if(checkintruder($query))
{
$count = 0;
foreach ($temp as $word)
{
// like product name
if($category!=0)
{
//make product search inside this category space.
}
else
{
//search product irrespective of categories.
}
//make query to ignore first ten items, or pass constraint as ascending timestamps of products.
$rs .= '<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3 BLOCK">
<a href="index.php?pagetype=product&productid=pid">
<div class="product">
<img alt="'.$altdata.'" src="images/searchpic.png" />
<div class="desc"><span>data about image</span></div>
</div>
</a>
</div>
';
if($count>=10)
{
$constraint++;
break;
}
else{
$count++;
}
}
//only 10 results at most at a time.
$rs .= '<div class="filler"></div>';
}
if($constraint>0)
{
$t = "<button class='loadmore' onclick='loadmore()' data-id='". $constraint. "' >Load more...</button>";
$rs .= $t;
}
header('content-type: application/json');
echo json_encode($rs);
?>