$navlist = ToolsInfClassify::FamilyTree($ALLCATE, $cate_id); //print_r($navlist); // 获得子栏目 $cur_catelist = ToolsInfClassify::ClassifyForMul($ALLCATE, $cate_id); if (!$cur_catelist) { // 没有子栏目 取父栏目的子栏目 $parent_id = ToolsInfClassify::FamilyTree($ALLCATE, $cate_id)[1]['cate_id']; $cur_catelist = ToolsInfClassify::ClassifyForMul($ALLCATE, $parent_id); } //print_r($cur_catelist);die(); // 本周热销 $hotlist = $mg->select(array('goods_id', 'goods_name', 'goods_price', 'goods_img'), 'is_hot order by sale_total desc limit 0,3'); // 本周新品 $newlist = $mg->select(array('goods_id', 'goods_name', 'goods_price', 'goods_img'), 'is_new order by sale_total desc limit 0,3'); // 或的该栏目下的所有商品 $allCateId = ToolsInfClassify::ChildrenId($ALLCATE, $cate_id); array_unshift($allCateId, $cate_id); // 分页显示 $list_per_page = 16; // 每页显示的条数 $sql = 'select count(*) from bl_goods where cate_id in (' . implode(',', $allCateId) . ')'; $list_total = $mg->getOne($sql); // 显示的总条数 $page_total = ceil($list_total / $list_per_page); // 总页数 // 获得当前显示的页 if (!isset($_GET['page']) || intval($_GET['page']) < 1) { $page = 1; } else { if (intval($_GET['page']) > $page_total) { $page = $page_total;
* Date: 2015/10/5 * Time: 17:55 * file: cateedithandle.php 编辑栏目信息的处理函数 */ require_once './common/include.php'; //print_r($_POST); $cate_id = $_POST['cate_id'] + 0; $cate_name = $_POST['cate_name']; $cate_desc = $_POST['cate_desc']; $newparent_id = $_POST['parent_id'] + 0; // 实例化数据库 $mu = new ModelUser('bl_cate'); // 判断新的父栏目是否在子栏目中 如果是的话 就返回错误 $field = array('cate_id', 'parent_id'); $res = $mu->select($field, 'is_delete=0 order by cate_id'); $allChildId = ToolsInfClassify::ChildrenId($res, $cate_id); // 父栏目选取错误 if (in_array($newparent_id, $allChildId) || $newparent_id == $cate_id) { echo '2'; return; } // 改变父栏目 $arr = array('parent_id' => $newparent_id, 'cate_name' => $cate_name, 'cate_desc' => $cate_desc); $res = $mu->update($arr, 'cate_id=' . $cate_id); //echo $res; if ($res != 1) { // 编辑失败 echo '1'; return; } else { // 编辑成功
$mu = new ModelUser('bl_cate'); //判断操作类型 query为查询要删除的栏目是否存在子栏目 delete为软删除 $type = $_POST['type']; $cate_id = $_POST['cate_id'] + 0; // 查询 if ($type == 'query') { $sql = "select count(c2.cate_id) from bl_cate as c1 left join bl_cate as c2 on c1.cate_id=c2.parent_id where c1.cate_id=" . $cate_id; $res = $mu->getOne($sql); echo $res; return; } else { if ($type == 'delete') { // 把要删除的栏目中所有的子栏目找出 把要删除的id全部放在allid中 $sql = "select * from bl_cate"; $res = $mu->getAll($sql); $childrenid = ToolsInfClassify::ChildrenId($res, $cate_id); $allid = array_merge(array($cate_id), $childrenid); $arr = array('is_delete' => 1); $where = 'cate_id in(' . implode(',', $allid) . ')'; $res = $mu->update($arr, $where); if ($res != count($allid)) { // 删除失败 echo '1'; return; } else { // 删除成功 echo '0'; return; } } }