www.gusucode.com > citySHOP B2C商城系统 进销存 2.0.6码程序 > upload/goodslist.php
<?php include_once './include/common.inc.php'; if (!$param) { showmessage('undefined_action'); } $BASEFILENAME = 'goodslist'; $headlinks = showlinks('css','style'); $jslinks = showlinks('js','common'); $cates = explode('-', $param); $cate1 = intval($cates[0]); $cate2 = intval($cates[1]); $cate3 = intval($cates[2]); $cate4 = intval($cates[3]); $cate5 = intval($cates[4]); $cate6 = intval($cates[5]); $cate7 = intval($cates[6]); $cate8 = intval($cates[7]); $cate9 = intval($cates[8]); $cate10 = intval($cates[9]); $ordertype = intval($cates[10]); $listtype = intval($cates[11]); $where = "WHERE g.gid=ga.gid AND g.selling='1' "; $where .= $cate1 ? " AND g.category1='$cate1' " : ''; $where .= $cate2 ? " AND g.category2='$cate2' " : ''; $where .= $cate3 ? " AND g.category3='$cate3' " : ''; $where .= $cate4 ? " AND ga.category4='$cate4' " : ''; $where .= $cate5 ? " AND ga.category5='$cate5' " : ''; $where .= $cate6 ? " AND ga.category6='$cate6' " : ''; $where .= $cate7 ? " AND ga.category7='$cate7' " : ''; $where .= $cate8 ? " AND ga.category8='$cate8' " : ''; $where .= $cate9 ? " AND ga.category9='$cate9' " : ''; $where .= $cate10 ? " AND ga.category10='$cate10' " : ''; foreach ($menus_array as $menu) { if ($menu['type'] == 'category' && $menu['id'] == $cate1) { $hovscript = $category_head . $menu['url'] . $category_end; break; } } $listtype = $listtype == 0 ? 2 : $listtype; $ordertype = $ordertype == 0 ? 1 : $ordertype; $gorder = $goodsrank[$ordertype]; $where .= "GROUP BY g.subject ORDER BY g.$gorder[0] $gorder[1]"; $hrefstr = "$goodslist_head$cate1-$cate2-$cate3-$cate4-$cate5-$cate6-$cate7-$cate8-$cate9-$cate10"; $tpp = $tpps['goodslist']; $page = max(1, intval($cates[12])); $start_limit = ($page - 1) * $tpp; $query = $db->query("SELECT g.gid FROM {$tablepre}goods g,{$tablepre}goodsattr ga $where"); $countnum = $db->num_rows($query); $multipage = multi($countnum, $tpp, $page, "$hrefstr-$ordertype-$listtype-%page%$goodslist_end"); $query = $db->query("SELECT g.category3,g.unit,g.sold,g.bbmark,g.zsold,g.subject,g.adsubject,g.photos,g.gid,g.replys,g.discount,g.asks,ga.*,g.eprice,GROUP_CONCAT(g.gid) as gids FROM {$tablepre}goods g,{$tablepre}goodsattr ga $where LIMIT $start_limit,$tpp"); $goods = $tmpgoods = array(); $gids = '0'; while ($arr = $db->fetch_array($query)) { $tmpgoods[] = $arr; $gids .= ','.$arr['gids']; } /** * 颜色 */ $cateids = $cates = array(); $query = $db->query("SELECT * FROM {$tablepre}goodsattr WHERE gid IN ($gids)"); while ($arr = $db->fetch_array($query)) { $cates[$arr['gid']] = array($arr['category4'],$arr['category5'],$arr['category6'],$arr['category7'],$arr['category8'],$arr['category9'],$arr['category10']); $cateids = array_merge($cateids,$cates[$arr['gid']]); } $cateidstr = implode(',', $cateids); $cateidstr = empty($cateidstr) ? '0' : $cateidstr; $hideattr = $categorys['hideattr']; $query = $db->query("SELECT * FROM {$tablepre}category WHERE categoryid IN ($cateidstr)"); while ($arr = $db->fetch_array($query)) { if (array_key_exists($arr['owner'], $hideattr)) { if($hideattr[$arr['owner']]['name'] == '颜色'){ $attrowner[$arr['categoryid']] = $arr; } } } foreach($tmpgoods as $arr){ $gdnum = $goods_start_number + $arr['gid']; $arr['zsold'] = $arr['sold']+$arr['zsold']; $arr['photos'] = unserialize($arr['photos']); $arr['zprice'] = number_format($arr['eprice'] * ($arr['discount'] / 10), 2); $attrs = ''; $atrids = explode(',',$arr['gids']); $atrids = array_unique($atrids); foreach($atrids as $gdid){ foreach($cates[$gdid] as $cid){ if(isset($attrowner[$cid])) { $attrs .= "<a href=\"$goods_head$gdid$goods_end\" target=\"_blank\" style=\"background:".$attrowner[$cid]['color']."\" title=\"".$attrowner[$cid]['name']."\"></a>"; } } } $arr['attrs'] = $attrs; $goods[] = $arr; } /** * 颜色 */ $catestr = $catetitle = $catekey = ''; $catetitle = $categorys[0][$cate1]['name']; if ($cate3) { $query = $db->query("SELECT * FROM {$tablepre}category WHERE owner='$cate3' OR categoryid='$cate3' ORDER BY `order` DESC,`categoryid` ASC"); $cateitems = $cateitemlist = array(); $cateitemids = $tagstr = ''; $i = 3; while ($arr = $db->fetch_array($query)) { if ($arr['owner'] != $cate3) { $catetitle = $arr['name']; } else { $i++; $arr['insernum'] = 'category' . $i; $cateitems[$i] = $arr; $cateitemids .= $tagstr . $arr['categoryid']; $tagstr = ','; } } $catesub = count($cateitems); if (!$catesub) { showmessage('分类未完善!'); } $query = $db->query("SELECT * FROM {$tablepre}category WHERE owner IN ($cateitemids) ORDER BY `order` DESC,`categoryid` ASC"); while ($arr = $db->fetch_array($query)) { $cateitemlist[$arr['owner']][] = $arr; } if (count($cateitemlist) < $catesub) { showmessage('undefined_action'); } foreach ($cateitems as $s => $item) { if ($item['display']) { continue; } $hovercate = ''; $varstr = 'cate' . $s; $varold = 'cateold' . $s; $$varold = $$varstr; $$varstr = 0; if ($$varstr == $$varold) { $hovercate = ' class="nonceA"'; } $liststr = "<a href=\"$goodslist_head$cate1-$cate2-$cate3-$cate4-$cate5-$cate6-$cate7-$cate8-$cate9-$cate10-$ordertype-$listtype-1$goodslist_end\"$hovercate>全部</a> "; foreach ($cateitemlist[$item['categoryid']] as $list) { $$varstr = $list['categoryid']; $hovercate = ''; if($item['name']=='品牌'){ $catekey .= ','.$list['name']; } if ($$varstr == $$varold) { $hovercate = ' class="nonceA"'; } $liststr .= "<a href=\"$goodslist_head$cate1-$cate2-$cate3-$cate4-$cate5-$cate6-$cate7-$cate8-$cate9-$cate10-$ordertype-$listtype-1$goodslist_end\"$hovercate>$list[name]</a> "; } $catestr .= "<li><span>$item[name]:</span>$liststr</li>"; $$varstr = $$varold; } } if($cate2){ $catechose = ''; $catetitle = $cate3 ? $catetitle : $categorys[$cate1][$cate2]['name']; foreach ($categorys[$cate2] as $arr) { $chked = $arr['categoryid'] == $cate3?'class="hov"':''; $arr['url'] = "$goodslist_head$cate1-$cate2-$arr[categoryid]-0-0-0-0-0-0-0-0-0-0$goodslist_end"; $catechose .= "<li><a $chked href=\"$arr[url]\">$arr[name]</a></li>"; } $catechose .= "<li><a ".($cate3?'':'class="hov"')." href=\"$goodslist_head$cate1-$cate2-0-0-0-0-0-0-0-0-0-0-0$goodslist_end\">查看全部</a></li>"; } $pagetitle = $catetitle; //left category history recommend foreach ($cachescript['goodslist'] as $cname) { include (cacheload($cname)); $$cname = $_MCACHE[$cname]; } $articles['mall_express'] = array_slice($articles['mall_express'], 0, 5); /** * 关键字 */ $sitekeywords = $dot = ''; if($cate3){ $sitekeywords = $catetitle.$catekey; }else{ foreach($categorys[$cate2] as $ct){ $sitekeywords .= $dot.$ct['name']; $dot = ','; } } $viewhistorys = viewhistory(); //rank $rankstr = ''; foreach ($goodsrank as $s => $rk) { $hoves = ''; if ($ordertype == $s) { $hoves = 'class="hove"'; } $rankstr .= "<a href=\"$hrefstr-$s-$listtype-1$goodslist_end\" $hoves>$rk[2]</a> "; } //pagebtn $pageprev = $pagenext = ''; $realpages = @ceil($countnum / $tpp); $pages = $tpps['maxpage'] && $tpps['maxpage'] < $realpages ? $tpps['maxpage'] : $realpages; $prev = $page <= 1 ? 0 : ($page - 1); $next = $page >= $pages ? 0 : ($page + 1); include (template('goodslist')); ?>