/var/www/(Del)wah-tung.com/html/sc/menu.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
244
245
246
247
248
249
250
251
 <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">主页</a></li>

<?php
   
function getLowerLevelFirstProd$id ){
      
$sqlCmd ="select p.productId, sum(i.productimageId) as num, p.productcatnamesc";
        
$sqlCmd .= " from  product p inner join productimage i on p.productId = i.productId";
        
$sqlCmd .= " where p.parentid = $id ";            
        
$sqlCmd .= " group by p.productId, p.productcatnamesc ";
        
$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)
         {
           
$rowmysql_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.specialcatnamesc";
        
$sqlCmd .= " from  special p left join specialimage i on p.specialId = i.specialId";
        
$sqlCmd .= " where p.parentid = $id ";            
        
$sqlCmd .= " group by p.specialId, p.specialcatnamesc";
        
$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)
         {
           
$rowmysql_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($resultMYSQL_ASSOC);
    
$menu_aboutus $row{'aboutusId'};
?>
<li><a href="aboutus.php?aboutusId=<?= $menu_aboutus?>">关於我们</a>
<ul>
<!-- SubMenu -->
<?
        loadm1
(001);

        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{'aboutusdescsc'} == "") {
               
// 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{'aboutusnamesc'} . "</a>";
               else{
                  
$a_child mysql_fetch_array($child_resMYSQL_ASSOC);
                  
$childid$a_child{'aboutusId'};
                  echo 
"<a href='aboutus.php?aboutusId=$childid'>"$row{'aboutusnamesc'} . "</a>";                  
               }
                } else {
                    echo 
"<a href='aboutus.php?aboutusId=".$row{'aboutusId'}."'>"$row{'aboutusnamesc'} . "</a>";
                }
                                        
                
loadm1($row{'aboutusId'}, $space+12);
                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($resultMYSQL_ASSOC);
    
$menu_product $row{'productId'};
?>
<li><a href="product.php?productId=<?=$menu_product?>">产品</a>
  <ul>
<?
        loadm2
(001);

        function 
loadm2($p$space$top)
        {
            
$sql "  select p.productId, sum(i.productimageId) as num, p.productcatnamesc";
            
$sql .= " from  product p left join productimage i on p.productId = i.productId";
            
$sql .= " where p.parentid = $p ";            
            
$sql .= " group by p.productId, p.productcatnamesc ";
            
$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{'productcatnamesc'} . "</a></li>";            
                else {
               
$a_child getLowerLevelFirstProd($row{'productId'});

                           
$childid$a_child{'productId'};
                    
                  echo 
"<a href='product.php?productId=$childid'>"$row{'productcatnamesc'}. "</a>";
            }
                    
                
                
loadm2($row{'productId'}, $space+12);
            }
            if ((
$top<>1) && ($num 0))
            {
                echo 
"</ul>";
            }

        }
?>
  </ul>
</li>

<?php    
    $cmd 
"SELECT specialId FROM special WHERE parentId>0 ORDER BY parentId DESC, sortby ASC LIMIT 1";
    
$result mysql_query($cmd);
    
$row mysql_fetch_array($resultMYSQL_ASSOC);
    
$menu_special $row{'specialId'};
    
    if (
$menu_special == "")
      { 
    echo 
"<li><a href='#'>特別推介</a><ul>";
    }else{
?>
<li><a href="special.php?specialId=<?=$menu_special?>">特別推介</a>
  <ul>
<?
}
        
loadm3(001);

        function 
loadm3($p$space$top)
        {
            
$sql "  select p.specialId, sum(i.specialimageId) as num, p.specialcatnamesc";
            
$sql .= " from  special p left join specialimage i on p.specialId = i.specialId";
            
$sql .= " where p.parentid = $p ";            
            
$sql .= " group by p.specialId, p.specialcatnamesc ";
            
$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{'specialcatnamesc'} . "</a>";            
                else {
               
$a_spec getLowerLevelFirstSpec$row{'specialId'} );
                           
$sqlt "SELECT specialcatnamesc 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>";
                
//    echo "<a href='special.php?specialId=".$a_spec{'specialId'}."'>". $a_spec{'specialcatnamesc'} . "</a></li>";    
              
}
                    
                
loadm3($row{'specialId'}, $space+12);
                echo 
"</li>";
            }
            if ((
$top<>1) && ($num 0))
            {
                echo 
"</ul>";
            }

        }
?>
  </ul>
</li>

<li><a href="news.php">最新消息</a></li>

<li><a href="contactus.php">联系我们</a></li>
</ul>
<br style="clear: left" />
</div>
</div></td>
 </tr>