2011-10-26 10 views
0

私はmysqlデータベースからデータを取得するモデルを持っています。私はテーブルとページネーションライブラリを使ってデータを表示しています。データを表示するときに、各行を削除するために使用される「DELETE」という列があります。テキスト「DELETE」を使用する代わりに、イメージを使用したいと思っています。私はモデルでそれを追加するために多くを試みたが、それは動作していません。親切に私を助けてくれますか?事前にImage of Code Igniter anchor()function

感謝:)

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

あなたがを働いていないによって何を意味するのか明確にしてください。あなたがhtml helperを使用している場合はaltをしたい場合は、(

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

を使用することができます

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

のか:

とにかく、今私はあなたの問題を推測していため は、あなたのエスケープがある、してみてくださいあなたは配列形式を使用する必要があります)

$img = array(
    'src' => 'support/images/icons/cross.png', 
    'alt' => 'Delete' 
); 

anchor('report/'.$row['batchname'], img($img)); 
+0

ありがとうございました。私の質問はあまり明確ではありませんでしたが、それでもあなたは正しい答えを得ました。再度、感謝します。 :) –

関連する問題