【问题标题】:Image in Code Igniter anchor() functionCode Igniter anchor() 函数中的图像
【发布时间】:2011-10-27 09:41:32
【问题描述】:

我有一个模型可以从 mysql 数据库中获取数据。我正在使用表格和分页库来显示数据。显示数据时有一个名为“DELETE”的列,用于删除每一行。我想使用图像而不是使用文本“DELETE”。我已经尝试了很多将它添加到模型中,但它不起作用。请您帮帮我好吗?

在此先感谢 :)

function batch_list()
{       
    $config['per_page'] = 15;
    $this->db->select('batchname, class, batchinstructor');
    $this->db->order_by("batchid", "desc"); 
    $rows = $this->db->get('batch',$config['per_page'],$this->uri->segment(3))->result_array();

    $sl = $this->uri->segment(3) + 1; // so that it begins from 1 not 0
    foreach ($rows as $count => $row)
        {
            array_unshift($rows[$count], $sl.'.');
             $sl = $sl + 1;

$rows[$count]['batchname'] = anchor('batch_list/get/'.$row['batchname'],$row['batchname']);
$rows[$count]['Edit'] = anchor('update_student/update/'.$row['batchname'],'Edit');
$rows[$count]['Delete'] = anchor('report/'.$row['batchname'],'<img src="base_url().support/images/icons /cross.png" alt="Delete" />"'); //<<< This is where I actually tried/want to add the image


            }
        return $rows;
    }

【问题讨论】:

    标签: codeigniter codeigniter-2


    【解决方案1】:

    请澄清你所说的不工作是什么意思。

    无论如何, 现在我猜你的问题是你的逃跑,试试:

    anchor('report/'.$row['batchname'], '<img src="'.base_url().'support/images/icons/cross.png" alt="Delete" />');
    

    或者如果你使用html helper,你可以使用

    anchor('report/'.$row['batchname'], img('support/images/icons/cross.png'));
    

    (如果您想要alt 属性,则需要使用数组形式)

    $img = array(
        'src' => 'support/images/icons/cross.png',
        'alt' => 'Delete'
    );
    
    anchor('report/'.$row['batchname'], img($img));
    

    【讨论】:

    • 非常感谢。我的问题不是很清楚,但您仍然设法回答正确。再次感谢。 :)
    猜你喜欢
    • 2015-01-09
    • 2016-03-10
    • 2016-09-27
    • 2011-01-31
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多