title: Retrieving image from php mysql database using specific id inserted by user
body: <p>I created a page for Inserting Image with some data into database in php/mysql . </p>
  
  <p>Table Structure</p>
  
  <p>name Varchar(20) |
  rollno Varchar(50) PRIMARY KEY |
  address Varchar(100) |
  image LONGBLOB</p>
  
  <p>but i don't know how to retrieve it using roll no. i.e. when user insert roll no in a text box and click on submit it should display all the details of that roll no including image. </p>
  
  <p>I am Using below code for image displaying.</p>
  
  <pre><code> &lt;?php
      $servername = "localhost";
      $username = "root";
      $password = "";
      $dbname = "galleryupload";
  
      // Create connection
      $conn = new mysqli($servername, $username, $password,$dbname);
  
      // Check connection
      if ($conn-&gt;connect_error) {
          die("Connection failed: " . $conn-&gt;connect_error);
      } 
  
      $sql = "SELECT * FROM `vision` where `rollno` = VCI/2012-13/C/03"; // manipulate id ok 
      $sth = mysqli_query($conn,$sql);
      $result=mysqli_fetch_array($sth);
  
      echo '&lt;img src="data:image/jpeg;base64,'.base64_encode( $result['image_file'] ).'"/&gt;'
  ?&gt;
  </code></pre>