<div>
<span></span>
<?php
//通过where条件来过滤子类,仅显示分类(一级)
$sql='select a.id,a.parentId,a.name,a.sort,count(b.id) as count from product_classify as a';
$sql.=' left join product_classify as b on b.parentId=a.id where a.parentId=0';
$sql.=' group by a.id order by a.sort';
$query=mysql_query($sql);
if(mysql_num_rows($query)){
while($arr=mysql_fetch_array($query)){
echo '<ul>';
echo "<li><img class=f src='https://www.jb51.net/images/plus.gif'>$arr[name]($arr[count])";
$sql="select a.id,a.name,a.sort from product_classify as a where a.parentId=$arr[id] group by a.id order by a.sort";
$query2=mysql_query($sql);
if(mysql_num_rows($query2)){
echo "<div><span></span>";
while($arr2=mysql_fetch_array($query2)){
echo "<ul>";
echo "<li><img class=t src='https://www.jb51.net/images/nofollow.gif'>$arr2[name]</li>";
echo "</ul>";
}
echo '</div>';
}
echo "</li></ul>";
}
}else{
echo '<li>暂无产品分类</li>';
}
?>
</div>
排序操作sort.php
复制代码 代码如下:
<?php
include("../conn.php");
$menu=$_GET['menu'];
switch(strtolower($menu[0])){
case 'productclassify':
$table='product_classify';
break;
}
for($i=1;$i<count($menu);$i++){
$sql='UPDATE '.$table.' SET sort=' . $i . ' WHERE id=' . $menu[$i];
mysql_query($sql);
}
?>
实例下载
二级目录拖拽排序的实现及演示源码下载
您可能感兴趣的文章: