我只是希望表格显示类别名称,而不是向用户显示其ID ...所以我只是在我的控制器中添加了$ data ['category']对象
控制器代码:
select
v.*
from
videos v
where
exists (
select 1
from videos v1
inner join
video_tags vt
on v1.id = vt.video_id
where
v1.id = v.id
and vt.tag in ('a', 'b')
)
查看代码:
$Query="group by product_image order by product_id";
$data["products"] = $this->insert->Select('product',$Query);
foreach ($data['products'] as $waste) {
$qry = "where id=".$waste->product_category;
$cat[] = $this->insert->select('category',$qry);
}
$data['category'] = $cat;
//print_r($data["products"]);
$this->load->view('manage/product/list',$data);
但我只是想向相应的行显示正确的类别。所以请帮助摆脱这个......等待可能的解决方案
答案 0 :(得分:0)
在您的控制器代码中,您有$data["products"]
。请改用$data['products']
。
答案 1 :(得分:0)
无需multiple
查询:
简单使用INNER JOIN
。
select * from product as p inner join category as c on p.product_category=c.id