Question

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,

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top