-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch.php
243 lines (225 loc) · 6.31 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCUMENT HTML>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<?php
if(!isset($_GET['s'])||$_GET['s']=="")//没有搜索内容 转回主页
{
echo '<meta http-equiv="refresh" content="0; url=index.php" />';
}
else
{
$s=$_GET['s'];
//echo $s;
if(isset($_GET['id']))$it=$_GET['id'];//获取id
else $it='t'.rand(0,200000);//生成随机id
if(isset($_GET['order']))$order=$_GET['order'];
else $order='price';//默认按价格排序
}
?>
<style type="text/css">
<!--
#kw,.btn{background:url(http://su.bdimg.com/static/superpage/img/spis_9762e054.png) no-repeat #fff}
#kw{
width:529px;
height:32px;
padding:4px 7px;
padding:6px 7px 2px\9;
font:16px arial;
border:1px solid #cdcdcd;
border-color:#9a9a9a #cdcdcd #cdcdcd #9a9a9a;
vertical-align:top;
}
.btn{width:95px;height:32px;padding:0;vertical-align:top;padding-top:2px\9;border:0;background-position:0 -35px;background-color:#ddd;cursor:pointer}
.STYLE4 {
font-size: x-large;
color: #FF0000;
font-weight: bold;
}
.STYLE5 {font-size: medium}
.STYLE6 {font-size: small}
-->
</style>
<html>
<head>
<link rel="shortcut icon" href="./source/4.ico" >
<title>你低我低-<?php echo $s;?></title>
</head>
<body>
<?php echo "<p style='font-size:14px; color:#000099; font-family:'微软雅黑''>欢迎<b>".$_SERVER['REMOTE_ADDR']."</b>的朋友</p>"; ?>
<hr>
<div>
<tr></tr><tr></tr><tr></tr>
<form name="form1" method="get" action="search.php">
<p>
<img src="./source/pic.jpg" width="125" height="50">
<input type="text" name="s" id="kw" value=<?php echo $s?> maxlength="100" style="width:474px;">
<input type="submit" name="sub" value="搜索" id="su" class="btn">
</p>
<b><b><input type="radio" name="order" value="price">价格升序
<input type="radio" name="order" value="price desc">价格降序
<input type="radio" name="order" value="sell">销量升序
<input type="radio" name="order" value="sell desc">销量降序
</form>
</div>
<?php
include_once ("conn/conn.php");//链接数据库
if ($_GET [page] == "") {//获取页码
$_GET [page] = 1;
}
;
if ($_GET [link_type] == "") {
$_GET [link_type] = 0;
}
;
?>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<table>
<tr>
<td height="330"> </td>
<td align="center" valign="top">
<table width="520" align="center">
<?php
$q=mysql_query("SHOW TABLES LIKE '".$it."'");
if(mysql_num_rows($q)<=0)
{
system("python get_taobao.py ".$s." ".$it);//抓取淘宝数据
system("python get_zcn.py ".$s." ".$it);//抓取亚马逊数据
}
$query_1 = mysql_query ( "select * from ".$it ); //获取数据库中总的记录数
if (mysql_num_rows ( $query_1 ) <= 0) { //判断值是否为空
?>
<tr>
<td colspan="2" align="center">没有数据!</td>
</tr>
<?php
} else {
$number = 0; //定义变量
if ($_GET [page]) {
$page_size = 40; //每页显示40条数据
$query = "select count(*) as total from ".$it;
$result = mysql_query ( $query );
$message_count = mysql_result ( $result, 0, "total" ); //统计总的记录数
$page_count = ceil ( $message_count / $page_size ); //计算总共有几页
$offset = ($_GET [page] - 1) * $page_size; //获取当前页的起始页
$query_2 = mysql_query ( "select * from ".$it." order by ".$order." limit $offset, $page_size" );
while ( $myrow_2 = mysql_fetch_array ( $query_2 ) ) { //循环输出
if (($number % 5) == 0) echo '<tr>';
?>
<td colspan="2" align="center"><!--输出数据库中数据-->
<table width="256" border="1" cellpadding="1" cellspacing="1"
bordercolor="#FFFFFF" bgcolor="#D0D0D0">
<tr>
<td width="106" bgcolor="#FFFFFF">
<div align="center"><a href="<?php echo $myrow_2 [url]; ?>"><img src="<?php echo $myrow_2 [pic]; ?>" width="100" height="120" border="0"></a></div>
</td>
<td width="170" valign="top" bgcolor="#FFFFFF">
<table width="170" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" align="center">价格:</td>
<td align="left"><span class="STYLE4"><?php echo $myrow_2 [price]; ?>元</span></td>
</tr>
<tr>
<td height="25" align="center">运费:</td>
<td align="left"><?php echo $myrow_2 [transport]; ?>元</td>
</tr>
<tr>
<td height="25" align="center">成交量:</td>
<td align="left"><?php echo $myrow_2 [sell]; ?></td>
</tr>
<tr>
<td height="25" align="center">来源:</td>
<td align="left"><?php echo $myrow_2 [from]; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="28" colspan="2" align="center" valign="top"
bgcolor="#FFFFFF">
<table width="240">
<tr>
<td height="5"></td>
</tr>
<tr>
<td><a href="<?php echo $myrow_2 [url]; ?>"><?php
$t=str_ireplace($s,"<font color='#FF0000'><strong>$s</strong></font>",$myrow_2 [name]);//对搜索关键字标红
echo $t; ?></a></td>
</tr>
<tr>
<td height="5"></td>
</tr>
</table>
</td>
</table>
<?php if ((++$number % 5) == 0)echo '</tr>';
}
}
}?>
</table>
<table height="30" border="1" align="right"
cellpadding="1" cellspacing="1" bordercolor="#FFFFFF"
bgcolor="#D0D0D0">
<tr>
<td align="center" bgcolor="#FFFFFF"><span
class="STYLE5"> <span class="STYLE6"></span>分页:
<?php
$next = $_GET [link_type] * 40;
$n = $link_type - 1;
$m = $link_type + 1;
$prev_page = $_GET [page] - 40;
?>
<?php
for($j = 1; $j <= $page_count; $j ++) {
$pnext = $next + $j;
if ($mm == 40) {
break;
}
if ($mm > $page_count) {
break;
}
if ($page_count - $vv < 40) {
if ($mm >= $page_count - $vv) {
break;
}
}
?>
<?php
echo "<a href='search.php?s=$s&id=".$it."&order=".$order."&page=$pnext'> $pnext </a>";
$mm = $mm + 1;
}
?>
</span></td>
</tr>
</table>
</td>
<td> </td>
</tr>
<tr>
<td height="109"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
</body>
</html>