1

I want to show a button with an imagen inside, but, I have a problem, the url of the image contains "base_url()" I mean...

<button type='button' class='btn btn-default btn-sm' id='deleteLevel' 
        value='".$key->cmpUsoID."'>
    <img src='<?=base_url();?>static/images/delete.png' alt='Borrar' title='Borrar'>
</button>

all this code are in my Controller, and, when I paste it in a view, my image doesn't exists :( The view put static/images/delete.png instead of http://www.mycompany.com/project/static/images/delete.png

Do you know if it is possible to show an image by this way? or how I have to put the url of my image?

  • you have major syntax errors. you're apparently concatenating a string, and then try to run php code INSIDE your string. php is not recursively embeddable/executable. – Marc B Jun 03 '15 at 21:37
  • Not familiar with code igniter but this looked promising: http://stackoverflow.com/questions/6449386/base-url-function-not-working-in-codeigniter And then syntax error Marc B. alluded to on the `value`... or other-way around suppose... – ficuscr Jun 03 '15 at 21:49
  • @MarcB I put this code in a variable, to send it via json array – Martin Rafael Pérez Lara Jun 03 '15 at 22:18

1 Answers1

1

Here is your code for view file

 <button type='button' class='btn btn-default btn-sm' id='deleteLevel'
                    value='<?php echo $key->cmpUsoID;?>'>
   <img src='<?php echo base_url('static/images/delete.png'); ?>' alt='Borrar' title='Borrar'>
 </button>

if you need in controller then

 $button = '<button type="button" class="btn btn-default btn-sm" id="deleteLevel" 
                    value="'.$key->cmpUsoID.'">
                <img src="'.base_url("static/images/delete.png").'" alt="Borrar" title="Borrar">
            </button>';
Rejoanul Alam
  • 5,435
  • 3
  • 39
  • 68