Chinaunix首页 | 论坛 | 博客
  • 博客访问: 97801
  • 博文数量: 28
  • 博客积分: 310
  • 博客等级: 二等列兵
  • 技术积分: 680
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-24 09:57
文章存档

2013年(10)

2012年(18)

分类: 系统运维

2012-11-02 16:21:44

修改includes/lib_goods.php
1.在sql语句
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' .
                'FROM ' . $GLOBALS['ecs']->table('category') .
                "WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
        $res = $GLOBALS['db']->getAll($sql);
的下面增加
$sql = "SELECT cat_id, COUNT(*) AS goods_num " .
   " FROM " . $GLOBALS['ecs']->table('goods') . " AS g " .
   " GROUP BY cat_id";
    $res2 = $GLOBALS['db']->getAll($sql);
    $newres = array();
    foreach($res2 AS $row)
    {
     $newres[$row['cat_id']] = $row['goods_num'];
    }
2.在cat_arr[$row['cat_id']]['id']   = $row['cat_id'];
下面增加
$cat_arr[$row['cat_id']]['num'] = !empty($newres[$row['cat_id']]) ? $newres[$row['cat_id']] : 0;
3.修改category_tree.lib库,写入num变量。
{$cat.name|escape:html}({$cat.num})

这样就可以搞定了!!




阅读(1350) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~