Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用图像CodeIgniter创建表_Php_Html_Codeigniter - Fatal编程技术网

Php 使用图像CodeIgniter创建表

Php 使用图像CodeIgniter创建表,php,html,codeigniter,Php,Html,Codeigniter,该表仅显示文本,其中“图像”列应显示实际图像,而不仅仅是图像的名称 其他一切都很好,工作也很完美,但是如何显示图片呢 控制器代码: function getData() { //check if the user is already logged in if($this->session->userdata('logged_in')) { //the user is already logged in -&g

该表仅显示文本,其中“图像”列应显示实际图像,而不仅仅是图像的名称

其他一切都很好,工作也很完美,但是如何显示图片呢

控制器代码:

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);

        }
    }
查看代码:

    $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);
$tmpl=array('table_open'=>'';
$this->table->set_标题(“产品列表”);
$this->table->set_标题('Name'、'productline'、'productscale'、'productdescription'、'Price per unit(€)'、'Image');
$this->table->set_模板($tmpl);
echo$this->table->generate($Products);

首先,您需要找到哪个部分是用户登录部分执行的

如果未加载登录节,则没有选项显示产品阵列中的图像

所以请确保这一点


如果加载了login部分,它将找不到product array(),因为在它重定向(“logged”)之前,请更正它并在控制器中为您工作,我必须更改它

$row['image']= "<img src='resources/images/thumbs/.$img'>";
这就是问题所在

$row['image']= "<img src='resources/images/thumbs/.$img'>";
$row['image']= img(array('src'=>'resources/images/thumbs/'.$img.'', 'alt'=>'','width'=>'100px', 'height'=>'100px'));