bla*_*elt 0 codeigniter codeigniter-2
我有一个模型从mysql数据库中获取数据.我正在使用表和分页库来显示数据.显示数据时,有一个名为"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;
}
Run Code Online (Sandbox Code Playgroud)
Hai*_*ood 14
请澄清你不工作的意思.
无论如何,现在我猜你的问题是你的逃避,试试:
anchor('report/'.$row['batchname'], '<img src="'.base_url().'support/images/icons/cross.png" alt="Delete" />');
Run Code Online (Sandbox Code Playgroud)
或者如果您使用的是html助手,则可以使用
anchor('report/'.$row['batchname'], img('support/images/icons/cross.png'));
Run Code Online (Sandbox Code Playgroud)
(如果你想要alt属性,你将需要使用数组形式)
$img = array(
'src' => 'support/images/icons/cross.png',
'alt' => 'Delete'
);
anchor('report/'.$row['batchname'], img($img));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7254 次 |
| 最近记录: |