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
上面的代碼是你需要打印的函數,導致這個函數打印查詢你試圖發送到後端和數據庫 –