/* 上一个商品下一个商品 */
$prev_gid = $db->getRow("SELECT goods_id,goods_name FROM " .$ecs->table('goods'). " WHERE cat_id=" . $goods['cat_id'] . " AND goods_id > " . $goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1");
if (!empty($prev_gid))
{
$prev_good['url'] = build_uri('goods', array('gid' => $prev_gid['goods_id']), $goods['goods_name']);
$prev_good['goods_name'] =$prev_gid['goods_name'];
$smarty->assign('prev_good', $prev_good);//上一个商品
}
$next_gid = $db->getRow("SELECT goods_id,goods_name FROM " . $ecs->table('goods') . " WHERE cat_id=".$goods['cat_id']." AND goods_id < ".$goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 order by goods_id desc limit 1");
if (!empty($next_gid))
{
$next_good['url'] = build_uri('goods', array('gid' => $next_gid['goods_id']), $goods['goods_name']);
$next_good['goods_name'] =$next_gid['goods_name'];
$smarty->assign('next_good', $next_good);//下一个商品
}
|