2013-03-01 61 views
0

我想使用codeigniter錨作爲調用方法來刪除我的數據庫中的行的鏈接。codeigniter錨圖像

<?php echo anchor("masterdata/delete_customer/$row->id",$row->customer_name) ?> 

這很好,但我想用圖像替換文字。類似:

<?php echo anchor('masterdata/delete_customer/$row->id',img(array('src'=>'images/delete_icon.png','border'=>'0','alt'=>'Delete'))); ?> 

上述語法產生一個錯誤:

The URI you submitted has disallowed characters. 

此外,是有可能替換爲BASE_URL路徑masterdata控制器路徑? 的BaseURL/masterdata/delete_customer ...

非常感謝一如既往,

回答

4

在您的示例代碼的問題是第二個示例使用單引號與周圍裏面的PHP變量第一paramater。它應該是:

<?php echo anchor('masterdata/delete_customer/'.$row->id, img(array('src'=>'images/delete_icon.png','border'=>'0','alt'=>'Delete'))); ?> 

或交換到雙引號。

+0

+1指出兩個選項。 – Malachi 2013-03-01 22:10:07