How to retrieve images from MySQL database

To retrieve the image from database you need the path of the image folder where you have moved/saved the image when you uploaded it. Now the code is here to retrieve the image:-


global $image_path;
$image_path ='image_upload/';

$query = "SELECT * FROM users WHERE id=2";

<img src="<?php echo $GLOBALS['image_path'].$row['profile_image'];?>" class="img-responsive">

global is used to get the value of that variable which is used with it at all over pages. You can put it in your functions file.

Read Also:

  1. Select Data from MySQL
  2. MySQL Update Data
  3. MySQL Insert Multiple

Leave a Reply

Notify of