title: How to retrieve image file paths from mysql database and display the images using php
body: <p>I'm trying to retrieve an image file path from mysql database using php and display it to a form that will then be used to send the images to our android app. I have search around everywhere and i found one that looks like my problem but it has not been solved so I'm trying to find another help.</p>
  
  <p>here is my php form for uploading images:
  inSTAGram.php</p>
  
  <pre><code>&lt;?php
  
  require('admin.config.inc.php');
  
  if(isset($_POST['upload'])){
  $image_name = $_FILES['image']['name'];
  $image_type = $_FILES['image']['type'];
  $image_size = $_FILES['image']['size'];
  $image_tmp_name = $_FILES['image']['tmp_name'];
  
  $path = "/home/stagcon2/public_html/StagConnect/admin/pictures/$image_name";
  
  if($image_name==''){
  echo "Don't just click! select an image please .";
  exit();
  }
  else{
  move_uploaded_file($image_tmp_name, $path);
  $mysql_path = $path."/".$image_name;
  $query = "INSERT INTO `inSTAGram`(`image_name`,`path`) VALUES ('$image_name','$mysql_path')";
  
  $query_params = array(
      ':image_name' =&gt; $image_name,
      ':mysql_path' =&gt; $path,
      );
  
  //execute query
  try {
      $stmt   = $db-&gt;prepare($query);
      $result = $stmt-&gt;execute($query_params);
  }
  catch (PDOException $ex) {
      // For testing, you could use a die and message. 
      //die("Failed to run query: " . $ex-&gt;getMessage());
  
      //or just use this use this one:
      $response["success"] = 0;
      $response["message"] = "Database Error. Couldn't Upload Image!";
      die(json_encode($response));
  }
  
  $response["success"] = 1;
  $response["message"] = "Image Uploaded Succesfully!";
  echo json_encode($response);
  }
  }   
  ?&gt;
  
  &lt;form action="inSTAGram.php" method="post" enctype="multipart/form-data"&gt;
  &lt;input type="file" name="image" &gt;
  &lt;input type="submit" name="upload" value="Upload" &gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>this one works just right! </p>
  
  <p>so here is my php form for the displaying of image;
  inSTAGramDisplay.php</p>
  
  <pre><code>&lt;?php
  require("admin.config.inc.php");
  
  //initial query
  $query = "Select * FROM inSTAGram";
  
  try {
  $stmt   = $db-&gt;prepare($query);
  $result = $stmt-&gt;execute($query_params);
  }
  catch (PDOException $ex) {
  $response["success"] = 0;
  $response["message"] = "Database Error!";
  die(json_encode($response));
  }
  
  // Finally, we can retrieve all of the found rows into an array using fetchAll 
  $rows = $stmt-&gt;fetchAll();
  
  
  if ($rows) {
  $response["success"] = 1;
  $response["message"] = "Image Available!";
  $response["images"]   = array();
  
  foreach ($rows as $row) {
      $rows             = array();
      $rows['image'] = 'http://www.stagconnect.com/StagConnect/admin/pictures?image_id=' . $rows['image_id'];
      $rows[] = $rows;        
  
      //update our repsonse JSON data
      array_push($response["images"], $image);
  }
  
  // echoing JSON response
  echo json_encode($rows);
  
  
  } else {
  $response["success"] = 0;
  $response["message"] = "No Image Available!";
  die(json_encode($response));
  }
  
  ?&gt;
  </code></pre>
  
  <p>this time, this one shows the image path and not the image, what i wanted to do is display the images itself. I just don't have any idea what the right thing to do here. any help will do. Thanks in advance!</p>