title: How to display database image in php (MYSQLi)
body: <p>Can you please help me, I know that this question has been asked numerous times. And I tried to do it myself, but it didn't work out. I have no clue.</p>
  
  <p>This is the code that uploads the image to the database: </p>
  
  <pre><code>&lt;?php
  $con = mysqli_connect('localhost','root','root', 'toevoegen');
  if (mysqli_connect_errno())
  {echo "Failed to connect to MySQL: " . mysqli_connect_error();}
  
  function GetImageExtension($imagetype)
   {
     if(empty($imagetype)) return false;
     switch($imagetype)
     {
         case 'image/bmp': return '.bmp';
         case 'image/gif': return '.gif';
         case 'image/jpeg': return '.jpg';
         case 'image/png': return '.png';
         default: return false;
     }
   }
  if (!empty($_FILES["uploadedimage"]["name"])) {
  
  $file_name=$_FILES["uploadedimage"]["name"];
  $temp_name=$_FILES["uploadedimage"]["tmp_name"];
  $imgtype=$_FILES["uploadedimage"]["type"];
  $ext= GetImageExtension($imgtype);
  $imagename=$_FILES["uploadedimage"]["name"];
  $target_path = "images/".$imagename;
  
  
  if(move_uploaded_file($temp_name, $target_path)) {
  $query_upload="INSERT into images_tbl ( images_path ) VALUES ('".$target_path."')";
  mysqli_query($con, $query_upload) or die("error in $query_upload == ----&gt; ".mysqli_error());  
  }else{
  
     exit("Error While uploading image on the server");
  } 
  
  }
  
  ?&gt;
  
  &lt;form action="saveimage.php" enctype="multipart/form-data" method="post"&gt;
  
  &lt;table style="border-collapse: collapse; font: 12px Tahoma;" border="1"      cellspacing="5" cellpadding="5"&gt;
  &lt;tbody&gt;&lt;tr&gt;
  &lt;td&gt;
  &lt;input name="uploadedimage" type="file"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input name="Upload Now" type="submit" value="Upload Image"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And this is the beginning of the display code:</p>
  
  <pre><code>$con = mysqli_connect('localhost', 'root', 'root', 'toevoegen');
  $query = mysqli_query($con,"SELECT 'images_path' FROM 'images_tbl'");
  while($row = mysqli_fetch_assoc($query)){
  
  echo "&lt;div class='tile' style='background-image: url(\"$row[images_path]\")'&gt;";
  } 
  </code></pre>
  
  <p>Can you please help me to complete this? </p>