Reputation: 59
I m learing codeigniter and i want to add an image in my view page. I am using tag but the image is not added in the page. So help me how i can add the image in view page of codigniter.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Blog</title>
</head>
<body>
<h2><img src="../images/logo.png"></h2>
<?php $this->load->view('blog/menu');
if ($query):foreach ($query as $post): ?>
<h4><?php echo $post->entry_name; ?> (<?php echo $post->entry_date; ?>)</h4>
<?php echo $post->entry_body; ?>
<?php endforeach;
else: ?>
<h4>No entry yet!</h4>
<?php endif; ?>
</body>
</html>
Upvotes: 0
Views: 20151
Reputation: 21
image in assets
<img src="<?php echo base_url(); ?>assets/images/image.png">
Upvotes: -1
Reputation: 69
store images in an images folder at the same level as the application folder . then just link to it like this using code.
<img src="<?php echo base_url('images/logo.png'); ?>" />
Upvotes: 3
Reputation: 5828
See, first you create a file with the name user_profile.php in the controller folder. no uppercase letters. To call a View page you created in the index:
function index()
{
$this->load_controller('myView');
}
this is an example from the link i sent you that is perfect, that shows peaces of a views and how to combine them to one code from the controller.
Please go to the codeigniter website and start learning the simple stuff. or search for codeigniter via youtube. you will find a lot!
Class User_Profile extends Controller
{
function index()
{
$this->load_controller('Left_Nav');
$this->load_controller('Content_Nav');
$this->load_controller('Login_Name');
$this->load_controller('Leaderboard', 'Board');
$this->Left_Nav->index(array('highlight_selected_page' => 'blah'));
$this->load('User');
$content_data = $this->User->get_profile_details();
$this->view->load('content', $content_data);
$this->Login_Name->index();
$this->Board->index();
}
}
Upvotes: 0
Reputation: 5665
Store images in an images folder at the same level as the application folder, Then just link to it like this:
<img src="../../images/image1.jpg" />
Upvotes: 1