2
我有一个模型,我已经加入了两个表,并选择了一些表值,然后我把它传递给我的控制器,并从控制器我是将它传递给查看页面。在查看页面中,我使用foreach()来获取值,然后显示它。但是问题在于同一张桌子连续反复重复。使用foreach()后,一次又一次重复相同的数据库表的值
型号
public function image_list()
{
$this->db->select('interior_testing.type_id,interior_testing.profile_pic, interior_testing.type, interior_testing.location, interior_testing.name, interior_image_testing.image_path');
$this->db->from('interior_testing');
$q=$this->db->join('interior_image_testing', 'interior_image_testing.type_id = interior_testing.type_id');
$this->db->where('interior_testing.category_id', 3);
$q = $this->db->get();
return $q->result();
}
控制器
public function index()
{
$this->load->model("Interior_listing_model","interior");
$data['particles'] = $this->interior->image_list();
// Load Interior Listing View
$this->load->view("interior/interior",$data);
}
查看
<?php foreach($particles as $particle): ?>
<div class="col-lg-4 col-md-4 col-sm-4 col-6 workimg">
<img src="assets/img/<?= $particle->image_path ?> " width="100%">
</div>
<?php endforeach; ?>
你正在尝试'$ this-> db-> get_compiled_select('interior_testing')'? –
不,我只是试图获取数据库表的值,这是我加入这两个表后得到的。 – Shantanu
上面的代码是你需要打印的函数,导致这个函数打印查询你试图发送到后端和数据库 –