Example #1
0
function dropProClass($result, $pid = 0)
{
    $arrClass = array();
    foreach ($result as $key => $v) {
        if ($pid == $v['parentid']) {
            $str = '';
            if ($pid != 0) {
                for ($i = 0; $i < $v['depth']; $i++) {
                    $str = $str . '&nbsp;&nbsp;&nbsp;';
                }
                $str = $str . '└ ';
            }
            $arrClass[$v['cid']] = $str . $v['cname'];
            $arrClass = $arrClass + dropProClass($result, $v['cid']);
            //合并数组
        }
    }
    return $arrClass;
}
Example #2
0
    if (isset($_REQUEST["keywords"])) {
        $where .= " and keywords like '%" . $_REQUEST["keywords"] . "%'";
    }
    if (isset($_REQUEST["new"])) {
        $where .= " and new=1";
    }
    if (isset($_REQUEST["tj"])) {
        $where .= " and tj=1";
    }
    if (isset($_REQUEST["hot"])) {
        $where .= " and hot=1";
    }
    if (isset($_REQUEST["cid"])) {
        $where .= " and (mpc.cid=" . $_REQUEST["cid"] . " or mpc0.cid=" . $_REQUEST["cid"] . ")";
    }
    $sql .= " where {$where} ORDER BY sort";
    $pagesize = 10;
    $currentPage = @$_REQUEST['page'] + 0;
    if (!is_numeric($currentPage) || $currentPage < 1 || empty($currentPage)) {
        $currentPage = 1;
    }
    $result = $db->SelectLimit($sql, $pagesize, ($currentPage - 1) * $pagesize);
    $result = $result->GetArray();
    $smarty->assign('prolist', $result);
    page("mycms_products_list", $pagesize, 3, $where, true, false, 'pagelink');
    $classList = $db->GetAll('SELECT cid,parentid,depth,cname FROM mycms_products_class ORDER BY csort');
    $classList = dropProClass($classList);
    $smarty->assign('class_options', $classList);
    $smarty->display('admin/pages/ProductList.html');
}
$db->close();