2011-10-26 31 views
0

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

感谢提前:)

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

回答

14

请说明您不工作的意思。

反正 现在我猜你的问题是你的转义,请尝试:

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

非常感谢。我的问题不是很清楚,但你仍然设法回答正确。再次感谢。 :) –