codeigniter is most valuable framework of PHP. Here you want to display image while you are fetch data from MySQL using codeigniter.
1) First you need to define a img tag. Like: <img src=””>
2) Now set a folder path in a variable. Like <?php $img_path=”assets/images/”; ?>
3) Scince you are using Codeigniter Framework then you need to set base_url() in your image path. like
<?php $img_path=base_url()."assets/images/"; ?>
4) For display imag set image path in the image src and put image value which image value you get from the MySQL. For example:
<img src="<?php echo $img_path.''.$val->user_image; ?>">
5) You can set image path directly in the image src. For example:
<img src="<?php echo base_url(); ?>assets/images/<?php echo $val->user_image; ?>">
6) If you want to set image fix width and height, then follow this code:
<img src="<?php echo base_url(); ?>assets/images/<?php echo $val->user_image; ?>" style="width: 80px; height: 80px;">
Hope it will be helpful for you.
If you need to more Codeigniter Tutorial help, you need to visit here: Codeigniter Tutorial.
Display image from a directory when fetch data from database in Codeigniter framework, echo the image value in the image tag. if you fetch data from database using loop or directly access Model, so follow the example, it will be helpful for you.
<?php foreach($user_details as $val) { ?> <img src="assets/images/<?php echo $att->user_file; ?>" alt="User Image" class="img"> <?php } ?>
Or try it
<?php $data=$this->Model->UserDetails($u_id); ?> <img src="<?php echo base_url();?>assets/images/<?php echo $data[0]->user_file; ?>"> ?>