0

I want to use html syntax in php and i want to use . instead of <?php ?> my code ig given below ,

$delete='<a class="confirm" onclick="return delete_event(<?php echo $value->id; ?>, '<?php echo base_url() . 'webtv/delete_channels' ?>', '<?php echo current_full_url(); ?>');" href="" ><i class="glyphicon glyphicon-trash text-red del" title="Delete"></i></a>';

Please help me.

Divakarcool
  • 473
  • 6
  • 20

3 Answers3

0
<?php 
$value = "value_1";                                 //$value->id;
$baseurl = "base_url"."/webtv/delete_channels";     //base_url()."/webtv/delete_channels";
$fullurl = "current_url";                           //current_full_url();
$delete="<a href='#' class='confirm' onclick=\"return delete_event('".$value."','".$baseurl."','".$fullurl."')\" >Click me</a>";
echo $delete;

?>

<script>
function delete_event(var1,var2,var3){
    alert(var1+" -- "+var2+" -- "+var3);
}

</script>
Aravind Pillai
  • 739
  • 7
  • 21
0

You can use sprintf function to solve this issue.

Solution is:

$delete = sprintf('<a class="confirm" onclick="return delete_event(%d, \'%s\',\'%s\');" href="" ><i class="glyphicon glyphicon-trash text-red del" title="Delete"></i>jkhklh</a>', $value->id, base_url() . 'webtv/delete_channels', current_full_url());
zajonc
  • 1,935
  • 5
  • 20
  • 25
0

I cleaned up your php syntax. I don't quite understand what you're trying to do, but the declaration below should give you an a tag containing what you want (a confirm delete button):

$delete='<a class="confirm" onclick="return delete_event($value->id, '.base_url().'webtv/delete_channels, '.current_full_url().');" href="" ><i class="glyphicon glyphicon-trash text-red del" title="Delete"></i></a>';

If you echo this on your webpage, assuming all of your other links are correct, it should work.

ccopland
  • 89
  • 4