문제

I am trying to use the codeigniter anchor as a link that calls a method to delete a row in my database.

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

This works great but I want to replace the text with an image. something like:

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

The above syntax produces an error:

The URI you submitted has disallowed characters.

In addition, is it possible to replace the masterdata controller path with a base_url path? baseurl/masterdata/delete_customer...

Many thanks as always,

도움이 되었습니까?

해결책

The problem in your example code is the second example uses single quote around the first paramater with the php variable inside. It should be:

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

Or swapped to the double quotes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top