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
|
<?php require_once('../webadmin/configure.php'); $result0 = mysql_query("SELECT * FROM home "); $row0 = mysql_fetch_array($result0,MYSQL_ASSOC); $result = mysql_query("SELECT * FROM sys_menu WHERE mpage = 'product' "); $row = mysql_fetch_array($result,MYSQL_ASSOC);
$result1 = mysql_query("SELECT * FROM product_cat WHERE pdcatid = ".safe_param($_GET['pdcatid'])." AND pdcatstatus = '1' ORDER BY pdcatsort ASC "); if (mysql_num_rows($result1) > 0){ $row1 = mysql_fetch_array($result1,MYSQL_ASSOC); } else { header("Location: index.php"); } // echo path function getLevel($p) { $sql1 = "select * from product_cat where pdcatid = ". $p ." "; $result1 = mysql_query($sql1); while ($row1 = mysql_fetch_array($result1,MYSQL_ASSOC)) { if ($row1{parentid} <> 0) { $n = $n . getLevel($row1{'parentid'}) ." > <a href='product.php?pdcatid=". $row1{'pdcatid'} ."'>". $row1{'pdcattitlesc'} ."</a>"; } else { $n = " > <a href='product.php?pdcatid=". $row1{'pdcatid'} ."'>". $row1{'pdcattitlesc'} ."</a>"; } } return $n; } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <title><?=$row1{'metatitlesc'};?></title> <meta name="keywords" content="<?=$row1{'metakeywordsc'};?>" /> <meta name="description" content="<?=$row1{'metadescsc'};?>" /> <link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript" src="../js/jquery.cycle.all.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.banner').cycle({ fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc... }); }); </script>
</head> <body> <div id="container"> <!-- Header --> <?php require_once('header.php');?> <!-- Main Content --> <div id="body"> <div id="body_content"> <div id="submenu"> <ul><?php // Left Menu $result3 = mysql_query("SELECT * FROM product_cat WHERE levelnum = '1' AND pdcatstatus = '1' ORDER BY pdcatsort ASC "); while ($row3 = mysql_fetch_array($result3,MYSQL_ASSOC)){ echo "<li><a href='product.php?pdcatid=".$row3{'pdcatid'}."'>".$row3{'pdcattitlesc'}."</a>"; $result4 = mysql_query("SELECT * FROM product_cat WHERE levelnum = '2' AND parentid = ".$row3{'pdcatid'}." AND pdcatstatus = '1' ORDER BY pdcatsort ASC "); if (mysql_num_rows($result4) > 0){ echo "<ul>"; while ($row4 = mysql_fetch_array($result4,MYSQL_ASSOC)){ echo "<li><a href='product.php?pdcatid=".$row4{'pdcatid'}."'>".$row4{'pdcattitlesc'}."</a>"; } echo "</ul>"; } echo "</li>"; }?> </ul> </div>
<div id="maincontent"> <?php if(!empty($row1{'pdcatbannersc'})) { echo '<div id="pagebanner"><a href="'.$row1{'pdcatbannerlinksc'}.'"><img src="../pagebanner/'.$row1{'pdcatbannersc'}.'" width="670" /></a></div>'; }?> <div id="pagetitle" class="pagetitle"><?=$row1{'pdcattitlesc'};?></div> <div id="path" class="path"><a href="index.php">主页</a><?=getLevel($row1{'pdcatid'});?></div> <div id="pagecontent" class="pagecontent"> <?php $adjacents = 5; $query = "SELECT COUNT(*) as num FROM product_det pd LEFT JOIN product_det_cat pdc ON pd.pdid = pdc.pdid WHERE pdc.pdcatid = ".$row1{'pdcatid'}." AND pd.pdstatus = '1' "; //echo 'query'.$query.'<br />'; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "product.php"; //your file name (the name of this file) $limit = 10; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql5 = "SELECT * FROM product_det pd LEFT JOIN product_det_cat pdc ON pd.pdid = pdc.pdid WHERE pdc.pdcatid = ".$row1{'pdcatid'}." AND pd.pdstatus = '1' "; $sql5 .= "ORDER BY pdc.psort LIMIT $start, $limit "; //echo $sql5; $result5 = mysql_query($sql5);
/* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$prev\">«</a>"; else $pagination.= "<span class=\"disabled\">«</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{ if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?pdcatid=".$row1{'pdcatid'}."&page=$next\">»</a>"; else $pagination.= "<span class=\"disabled\">»</span>"; $pagination.= "</div>\n"; }
?> <?php while ($row5 = mysql_fetch_array($result5,MYSQL_ASSOC)){ $result6 = mysql_query("SELECT * FROM product_img WHERE pdid = ".$row5{'pdid'}." ORDER BY pimgsort ASC "); $row6 = mysql_fetch_array($result6,MYSQL_ASSOC); if(mysql_num_rows($result6) > 0 ){ $getsize = getimagesize("../products/thumb/".$row6{'pimgfile'}) ; if($getsize[0] > $getsize[1]){ // 0=w 1=h $pimgfile = "<img src='../products/thumb/".$row6{'pimgfile'}."' width='160' />"; } else { $pimgfile = "<img src='../products/thumb/".$row6{'pimgfile'}."' height='160' />"; } } else { // No image $pimgfile = "<img src='../products/space.png' width='160' height='160' />"; } ?> <table width="670" border="0" cellspacing="0" cellpadding="0" class="prodlisttable"> <tr> <td width="160" height="160" align="left" valign="top" class="prodlistimg"><a href="product_detail.php?pdcatid=<?=$row5{'pdcatid'};?>&pdid=<?=$row5{'pdid'};?>"><?=$pimgfile;?></a></td> <td align="left" valign="top"><div class="prodlist_name"><a href="product_detail.php?pdcatid=<?=$row5{'pdcatid'};?>&pdid=<?=$row5{'pdid'};?>"><?=$row5{'pdcode'};?> <?=$row5{'pdtitlesc'};?></a></div> <div class="prodlist_feat"><?=$row5{'pdfeatsc'};?></div></td> </tr> </table> <?php } ?></div> <div id="pagination"><?=$pagination;?></div> </div> <div class="clear"></div> </div> </div> <!-- Footer --> <?php require_once('footer.php');?> </div> </body> </html>
|