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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
<tr> <td height="40" align="center" valign="top" background="../images/menubg.jpg"><div class="colMenu"> <div id="myslidemenu" class="jqueryslidemenu"> <ul> <li><a href="index.php">Home</a></li>
<?php
// function for level searching function getLowerLevelFirstProd( $id ){ $sqlCmd ="select p.productId, sum(i.productimageId) as num, p.productcatname"; $sqlCmd .= " from product p inner join productimage i on p.productId = i.productId"; $sqlCmd .= " where p.parentid = $id "; $sqlCmd .= " group by p.productId, p.productcatname "; $sqlCmd .= " order by p.sortby"; //check does it have a product $tmprst = mysql_query($sqlCmd); if( mysql_num_rows($tmprst) > 0){ $row=mysql_fetch_assoc($tmprst); return $row; } //check if there are child product else{ $sqlCmd= "SELECT productId FROM product WHERE parentid=$id ORDER BY sortby ASC"; $tmprst = mysql_query($sqlCmd); // there are child product in this category if(mysql_num_rows($tmprst) > 0) { $row= mysql_fetch_assoc($tmprst); return getLowerLevelFirstProd($row{'productId'}); } else { return array("productId"=>$id); } } } function getLowerLevelFirstSpec( $id ){ $sqlCmd ="select p.specialId, sum(i.specialimageId) as num, p.specialcatname"; $sqlCmd .= " from special p left join specialimage i on p.specialId = i.specialId"; $sqlCmd .= " where p.parentid = $id "; $sqlCmd .= " group by p.specialId, p.specialcatname"; $sqlCmd .= " order by p.sortby"; //check does it have a product $tmprst = mysql_query($sqlCmd); if( mysql_num_rows($tmprst) > 0){ $row=mysql_fetch_assoc($tmprst); return $row; } //check if there are child product else{ $sqlCmd= "SELECT specialId FROM special WHERE parentid=$id ORDER BY sortby ASC"; $tmprst = mysql_query($sqlCmd); // there are child product in this category if(mysql_num_rows($tmprst) > 0) { $row= mysql_fetch_assoc($tmprst); return getLowerLevelFirstProd($row{'specialId'}); } else { return array("specialId"=>$id); } } }
$cmd = "SELECT aboutusId FROM aboutus WHERE parentId=0 ORDER BY sortby ASC LIMIT 1"; $result = mysql_query($cmd); $row = mysql_fetch_array($result, MYSQL_ASSOC); $menu_aboutus = $row{'aboutusId'}; ?> <li><a href="aboutus.php?aboutusId=<?= $menu_aboutus?>">About Us</a> <ul> <!-- SubMenu --> <? loadm1(0, 0, 1);
function loadm1($p, $space, $top) { $sql = "SELECT * "; $sql .= "FROM aboutus "; $sql .= "where parentid = $p "; $sql .= "order by sortby";
$result1 = mysql_query($sql); $n=1; $count = mysql_num_rows($result1); $num = mysql_num_rows($result1); if (($top<>1) && ($num > 0)) { echo "<ul>"; } while ($row = mysql_fetch_array($result1,MYSQL_ASSOC)) { echo "<li>"; if ($row{'aboutusdesc'} == "") { // test and get if there are child underhood $sql_child = "SELECT aboutusId FROM aboutus WHERE parentid=".$row{'aboutusId'}." ORDER BY sortby ASC"; $child_res = mysql_query($sql_child); if(mysql_num_rows($child_res) ==0) echo "<a>". $row{'aboutusname'} . "</a>"; else{ $a_child = mysql_fetch_array($child_res, MYSQL_ASSOC); $childid= $a_child{'aboutusId'}; echo "<a href='aboutus.php?aboutusId=$childid'>". $row{'aboutusname'} . "</a>"; } } else { echo "<a href='aboutus.php?aboutusId=".$row{'aboutusId'}."'>". $row{'aboutusname'} . "</a>"; } loadm1($row{'aboutusId'}, $space+1, 2); echo "</li>"; } if (($top<>1) && ($num > 0)) { echo "</ul>"; }
} ?> </ul> </li> <?php $cmd = "SELECT productId FROM product WHERE parentId>0 ORDER BY parentId ASC, sortby ASC LIMIT 1"; $result = mysql_query($cmd); $row = mysql_fetch_array($result, MYSQL_ASSOC); $menu_product = $row{'productId'}; ?> <li><a href="product.php?productId=<?=$menu_product?>">Products</a> <ul> <? loadm2(0, 0, 1);
function loadm2($p, $space, $top) { $sql = " select p.productId, sum(i.productimageId) as num, p.productcatname"; $sql .= " from product p left join productimage i on p.productId = i.productId"; $sql .= " where p.parentid = $p "; $sql .= " group by p.productId, p.productcatname "; $sql .= " order by p.sortby";
$result1 = mysql_query($sql); $n=1; $count = mysql_num_rows($result1); $num = mysql_num_rows($result1); if (($top<>1) && ($num > 0)) { echo "<ul>"; } while ($row = mysql_fetch_array($result1,MYSQL_ASSOC)) { echo "<li>"; if ($row{'num'} <> '') echo "<a href='product.php?productId=".$row{'productId'}."'>". $row{'productcatname'} . "</a>"; else { // test and get if there are child underhood /*$sql_child = "SELECT productId FROM product WHERE parentid=".$row{'productId'}." ORDER BY sortby ASC"; $child_res = mysql_query($sql_child); if(mysql_num_rows($child_res) ==0) echo "<a>". $row{'productcatname'}. "</a></li>"; else{ }*/ $a_child = getLowerLevelFirstProd($row{'productId'});
$childid= $a_child{'productId'}; echo "<a href='product.php?productId=$childid'>". $row{'productcatname'}. "</a>"; } loadm2($row{'productId'}, $space+1, 2); echo "</li>"; } if (($top<>1) && ($num > 0)) { echo "</ul>"; }
} ?> </ul> </li>
<?php $cmd = "SELECT specialId FROM special WHERE parentId>0 ORDER BY parentId ASC, sortby ASC LIMIT 1"; $result = mysql_query($cmd); $row = mysql_fetch_array($result, MYSQL_ASSOC); $menu_special = $row{'specialId'}; if ($menu_special == "") { echo "<li><a href='#'>Special Offers</a><ul>"; }else{ ?> <li><a href="special.php?specialId=<?=$menu_special?>">Special Offers</a> <ul> <? } loadm3(0, 0, 1);
function loadm3($p, $space, $top) { $sql = " select p.specialId, sum(i.specialimageId) as num, p.specialcatname"; $sql .= " from special p left join specialimage i on p.specialId = i.specialId"; $sql .= " where p.parentid = $p "; $sql .= " group by p.specialId, p.specialcatname "; $sql .= " order by p.sortby";
$result1 = mysql_query($sql); $n=1; $count = mysql_num_rows($result1); $num = mysql_num_rows($result1); if (($top<>1) && ($num > 0)) { echo "<ul>"; } while ($row = mysql_fetch_array($result1,MYSQL_ASSOC)) { echo "<li>"; if ($row{'num'} <> '') echo "<a href='special.php?specialId=".$row{'specialId'}."'>". $row{'specialcatname'} . "</a>"; else { //echo "<a>". $row{'specialcatname'} . "</a></li>"; $a_spec = getLowerLevelFirstSpec( $row{'specialId'} ); $sqlt = "SELECT specialcatname FROM special WHERE parentId=0"; $rowt = mysql_fetch_array(mysql_query($sqlt)); $s_name= $rowt[0];//$a_spec{'specialcatname'}; echo "<a href='special.php?specialId=".$a_spec{'specialId'}."'>". $s_name . "</a>"; } loadm3($row{'specialId'}, $space+1, 2); echo "</li>"; } if (($top<>1) && ($num > 0)) { echo "</ul>"; }
} ?> </ul> </li>
<li><a href="news.php">News & Events</a></li>
<li><a href="contactus.php">Contact Us</a></li> </ul> <br style="clear: left" /> </div> </div></td> </tr> <!--<table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="menutxt"><a href="index.php">Home</a></td> <td width="16"><img src="../images/menucut.jpg" width="16" height="40" /></td> <td class="menutxt"><a href="aboutus.php?aboutusId=1">About Us </a></td> <td width="16"><img src="../images/menucut.jpg" width="16" height="40" /></td> <td class="menutxt"><a href="product.php">Products</a></td> <td width="16"><img src="../images/menucut.jpg" width="16" height="40" /></td> <td class="menutxt"><a href="special.php">Special Offers</a> </td> <td width="16"><img src="../images/menucut.jpg" width="16" height="40" /></td> <td class="menutxt"><a href="news.php">News & Events</a> </td> <td width="16"><img src="../images/menucut.jpg" width="16" height="40" /></td> <td class="menutxt"><a href="contactus.php">Contact Us</a> </td> </tr> </table>-->
|