首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在显示屏顶部展示特色产品

在显示屏顶部展示特色产品
EN

Stack Overflow用户
提问于 2015-01-24 05:54:40
回答 1查看 151关注 0票数 0

我在opencart上工作,并使用下面提到的查询获取产品列表,这些产品在顶部显示最新的产品。

代码语言:javascript
复制
   $result = mysqli_query($con,"select p.image,p.price,p.store_name,p.deal_title_url,p.shop_now_url,p.coupon_code,p.special_deal_txt,p.special_comment_txt,s.price,d.name,p.date_added from oc_product p, oc_product_special s,oc_product_description d where p.product_id=s.product_id and p.product_id=d.product_id order by p.date_added DESC $limit;");

注- 1.限制用于分页2.从多个表取数据

现在我想在显示屏的顶部展示所有的特色产品。因此,基本上,特色数组中的产品必须始终显示在顶部,然后根据创建日期显示其余产品。

特色产品id保存在数组中- $featured_array

如何做到这一点?

请注意,特色产品的数量可能有所不同。

EN

回答 1

Stack Overflow用户

发布于 2015-01-24 06:26:05

尝试使用UNION。在第一个查询中获取特色产品,在第二个查询中放入当前查询。Limit适用于联合结果

代码语言:javascript
复制
(
select p.image,p.price,p.store_name,p.deal_title_url,p.shop_now_url,p.coupon_code,p.special_deal_txt,p.special_comment_txt,s.price,d.name,p.date_added from oc_product p, oc_product_special s,oc_product_description d where p.product_id=s.product_id and p.product_id=d.product_id AND p.product_id IN($featuredProductsIds) order by p.date_added DESC 
)
UNION
(
select p.image,p.price,p.store_name,p.deal_title_url,p.shop_now_url,p.coupon_code,p.special_deal_txt,p.special_comment_txt,s.price,d.name,p.date_added from oc_product p, oc_product_special s,oc_product_description d where p.product_id=s.product_id and p.product_id=d.product_id order by p.date_added DESC 
)
$limit;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28119344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档