如何从链接到项目id的文件夹中检索图像



主要问题是模型,我不知道如何连接两个表,这样我就可以显示存储在不同位置的带有图像的项目。型号

$this->db->select('bs_items.id, bs_items.description, bs_items.title, 
bs_items.touch_count,bs_items.price');
$this->db->from('core_images');
$this->db->join('bs_items', 'core_images.img_parent_id = 
bs_items.id');
$this->db->order_by('bs_items.touch_count', 'desc');
$this->db->from('bs_items');

控制器:

this->load->model('Popular_car');
$this->load->model('Recent_car');
$data['popular_cars']= $this->Popular_car->popular_car();
$data['recent_cars']=$this->Recent_car->get_listing();
$this->load->view('templates/header');
$this->load->view('pages/home', $data);
$this->load->view('pages/home_recent', $data);
$this->load->view('templates/footer');

请用您所做的一些代码或数据库结构更新您的问题。我将根据我使用您给定的代码片段所理解的内容给出答案。

型号

function get_items()
{
$this->db->select('*');
$this->db->from('core_images');
$this->db->join('bs_items', 'core_images.img_parent_id = 
bs_items.id');
$this->db->order_by('bs_items.touch_count', 'desc');
$query = $this->db->get();
return $query->result();
}

控制器

function get_allitems() 
{ 
$this->load->model('model_name');
$data['items'] = $this->model_name->get_items(); 
$this->load->view('view_name', $data); 
}

查看

<?php foreach ($items as $row): ?> 
<h1><?php echo $row->title;?></h1>
<p><?php echo $row->touch_count;?></p>
<p><?php echo $row->price;?></p>
<p><?php echo $row->description;?></p>
<img src="<?php echo base_url().'path_of_image/'.$row->image_from_db; ?> 
<?php endforeach; ?>  

$myString=$this->db->get_where('profile_table',array('id'=>$edit((->row((->file_name_galery;

//$json11='{"1":"s1.jpg","2":"s2.jpg">
$array=json_decode($myString(;

if (empty($array)) {
echo '<p class="tx-danger"> NO IMAGE..</p>';
}         
foreach($array as $key => $photo) { <div class="column_galery text-center zoom_img_app"> 
<a  onclick="selected_photo('  echo $photo;  ')" data-toggle="modal" data-target="#edit_image_mod" > 
<img class=""   src="http://yourapp.com/uploads/profile_gallery/  echo $photo;  " style="width:100%"> <span  class="tx-danger">DELETE</span> </a>
</div> } 

相关内容

  • 没有找到相关文章