Akbar Yusrofi Akbar Yusrofi - 5 months ago 25
PHP Question

how to create hyperlink by image in codeigniter

Usually in php I will call hyperlink by image

<a href="siswa/"><img src="image/.png"></a>


How about in CI? Maybe use controler or helper?

Answer

You have to try more than this

In View

<a href="<?php echo base_url() ;?>index.php/ControllerName/MethodName">
    <img src="<?php echo base_url() ;?>path/to/image.png">
</a>

Ex

<a href="<?php echo base_url() ;?>index.php/home/image">
    <img src="<?php echo base_url() ;?>image/edit.png">
</a>

In Controller (home.php)

public function image()
{
    # code...
}

Note : - base_url() is used to print the Codeigniter project path

Comments