[英]Restrict Codeigniter session creation in table for particular user agent
[英]Creation of table with images CodeIgniter
該表僅顯示文本,其中“圖像”列應顯示實際圖像,而不僅僅是圖像名稱。
其他一切都很好並且可以正常工作,但是如何顯示圖片呢?
控制器代碼:
function getData()
{
//check if the user is already logged in
if($this->session->userdata('logged_in'))
{
//the user is already logged in -> display the secret content
redirect('logged');
//get the session data
$session_data = $this->session->userdata('logged_in');
//get the username from the session and put it in $data
$data['user'] = $session_data['username'];
$config['base_url'] = site_url('LittleController/getData/');
$config['total_rows'] = $this->littlemodel->record_count('products');
$config['per_page'] = 10;
$this->pagination->initialize($config);
$data['Products'] = $this->littlemodel->getData(10, $this->uri->segment(3));
foreach ($data['Products'] as &$row)
{
$img = $row['image'];
$row['image']= "<img src='resources/images/thumbs/.$img'>";
//img('resources/images/thumbs/'.$img);
}
//$data["links"] = $this->pagination->create_links();
$this->load->view('mainpage1', $data);
}
else
{
//user isn't logged in -> display login form
$data['user'] = "Guest";
$config['base_url'] = site_url('LittleController/getData/');
$config['total_rows'] = $this->littlemodel->record_count('products');
$config['per_page'] = 10;
$this->pagination->initialize($config);
$data['Products'] = $this->littlemodel->getData(10, $this->uri->segment(3));
$data["links"] = $this->pagination->create_links();
$this->load->view('mainpage1', $data);
}
}
型號代碼:
public function getData($limit, $offset)
{
$this->db->limit($limit, $offset);
$this->db->select('productName');
$this->db->select('productLine');
$this->db->select('productScale');
$this->db->select('productDescription');
$this->db->select('buyPrice');
$this->db->select('image');
$resultset = $this->db->get('products');
return $resultset->result_array();
}
查看代碼:
$tmpl = array ( 'table_open' => '<table z-index="1000" id="table">' );
$this->table->set_caption("List of Products");
$this->table->set_heading('Name','Product Line','Product Scale','Product Description','Price per unit(€)','Image');
$this->table->set_template($tmpl);
echo $this->table->generate($Products);
首先,您需要找到執行用戶登錄部分的部分。
如果未加載登錄部分,則沒有選項來顯示產品陣列的圖像。
所以請確保
如果登錄部分已加載,則找不到產品array(),因為在重定向(“已記錄”)之前,請對其進行更正並為您工作
在控制器中我必須改變
$row['image']= "<img src='resources/images/thumbs/.$img'>";
至
$row['image']= img(array('src'=>'resources/images/thumbs/'.$img.'', 'alt'=>'','width'=>'100px', 'height'=>'100px'));
這就是問題所在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.