title: php mysql retrive the uploaded photo from the database
body: <p>I am trying to display as a result for the search of user list with the identical result retrieved from the database so but the system display the path and not the image itself. 
  Can anyone help me?</p>
  
  <p>Until now I started with the query of the search by name: </p>
  
  <p>search.php</p>
  
  <pre><code>&lt;?php
  session_start();
  if($_SESSION['login'] != 'true'){
          header("location:index.php");
      }
  
  
     $login = ($_SESSION['login']);
     $userid = ($_SESSION['user_id']);
     $login_user = ($_SESSION['username']);
     $fname = ($_SESSION['first_name']);
     $lname = ($_SESSION['last_name']);
     $sessionaddres =($_SESSION['address']);
  
  
  require_once('for members/scripts/connect.php'); 
  
  // function for selecting names
  function nameQuery(){
  
    $nameData = mysql_query("SELECT * FROM user") or die("could select database");
  
    while($record = mysql_fetch_array($nameData)){
  
       echo'&lt;option value="' . $record['user_name'] .  '"&gt;' . $record['user_name'] . '&lt;/option&gt;';
  
    }
  
  }
  
  
  
  // function for select by specialization
  
  function specializationQuery(){
  
  $specData = mysql_query("SELECT * FROM specialization");
  
    while($recordJob = mysql_fetch_array($specData)){
  
       echo'&lt;option value="' . $recordJob['specialization_name'] .  '"&gt;' . $recordJob['specialization_name'] . '&lt;/option&gt;';
  
    }
  
  
  }
  
  if(isset($_POST['search']))
  {
  
  
      $Sgov = $_POST['governorate'];
      @$Sdist = $_POST['district'];
      @$Svillage = $_POST['village'];
  
  
      // query  search by name
      if(isset($_POST['name']))
      {
          $Sname =$_POST['name'];
      $sql = mysql_query("SELECT first_name, last_name, profile_pic FROM user WHERE user_name ='$Sname'")or die(mysql_error());
  
      if($sql)
      {
       while($getrow = mysql_fetch_array($sql))
       {
          $firstname = $getrow['first_name'];
          $lastname = $getrow['last_name'];
          $profilepic = $getrow['profile_pic'];
  
          if($profilepic == "") 
           {
               $profile_pic = "images/default_img.jpg";
           }
           else
           {
               $profile_pic = "userdata/profile_pics/".$profilepic;
           }
  
  
  
           echo "&lt;ul&gt;
            &lt;li&gt;
             ".$firstname. " ".$lastname ."
            &lt;/li&gt;
            &lt;li&gt;
             &lt;img style='width:80px' src='".$profile_pic . "'&gt;
            &lt;/li&gt;
           &lt;/ul&gt;";
       }
     }
     else
     {
         echo "their was no result!!!!";
     }
    }
  }
  
  // search by specialization
  
  if(isset($_POST['specialization']))
  {
      $Sspec = $_POST['specialization'];
      $sql = mysql_query("first_name, last_name, profile_pic FROM user WHERE specialization = '$Sspec'")or die(mysql_error());
      if($sql)
      {
       while($getrow = mysql_fetch_array($sql))
       {
          $firstname = $getrow['first_name'];
          $lastname = $getrow['last_name'];
          $profilepic = $getrow['profile_pic'];
  
          if($profilepic == "") 
           {
               $profile_pic = "images/default_img.jpg";
           }
           else
           {
               $profile_pic = "userdata/profile_pics/".$profilepic;
           }
  
  
  
           echo "&lt;ul&gt;
            &lt;li&gt;
             ".$firstname. " ".$lastname ."
            &lt;/li&gt;
            &lt;li&gt;
             &lt;img style='width:80px' src='".$profile_pic . "'&gt;
            &lt;/li&gt;
           &lt;/ul&gt;";
       }
     }
     else
     {
         echo "their was no result!!!!";
     }
  
  }
  ?&gt;
  
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;search page&lt;/title&gt;
  &lt;link href="style/stylesheet.css" rel="stylesheet" type="text/css" /&gt;
  &lt;script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
   $(document).ready(function(){
                  $("select#district").attr("disabled","disabled");
                  $("select#village").attr("disabled","disabled");
                  $("select#governorate").change(function(){
                  $("select#district").attr("disabled","disabled");
                  $("select#district").html("&lt;option&gt;wait...&lt;/option&gt;");
                  var id = $("select#governorate option:selected").attr('value');
                  $.post("select_district.php", {id:id}, function(data){
                      $("select#district").removeAttr("disabled");
                      $("select#district").html(data);
                  });
              });
              $("select#district").change(function(){ 
              id = $(this).val(); 
              $("select#village").attr("disabled","disabled");
              $("select#village").html("&lt;option&gt;wait...&lt;/option&gt;");
              $.post("select_village.php", {id:id}, function(data){
  
  
              $("select#village").removeAttr("disabled");
              $("select#village").html(data);
           });
          });
              $("form#registerform").submit(function(){
                  var cat = $("select#governorate option:selected").attr('value');
                  var type = $("select#district option:selected").attr('value');
                  var village = $("select#village option:selected").attr('value');
  
              });
      });
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  
  &lt;body&gt;
  &lt;div class="container"&gt;
  &lt;!--&lt;?php require_once('header.php'); ?&gt;--&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  
    &lt;!-- &lt;?php require_once('leftsideBar2.php'); ?&gt;--&gt;
  
  
     &lt;div id="search-title"&gt;Search section&lt;/div&gt;
      &lt;div id="search-form"&gt;
      &lt;?php include "select.class.php"; ?&gt;
          &lt;form action="search.php" method="post"&gt;
  
           Search By Name:&lt;br /&gt;
           &lt;select name="name" &gt;
              &lt;?php nameQuery(); ?&gt;
               &lt;option id="0"&gt;-- select By UserName --&lt;/option&gt;
               &lt;/select&gt;
             &lt;br/&gt;&lt;br/&gt;
             Search By Governorate:&lt;br /&gt;
  
          &lt;select id="governorate" name = 'governorate'&gt;
                  &lt;?php echo $opt-&gt;ShowGovernorate(); ?&gt;
                  &lt;/select&gt;
             &lt;br /&gt;&lt;br/&gt;
             Search by District:&lt;br /&gt;
  
        &lt;select id="district" name="district"&gt;
                      &lt;option value="0"&gt;choose...&lt;/option&gt;
                  &lt;/select&gt;
  
             &lt;br /&gt;&lt;br/&gt;
             Search by Cities:&lt;br /&gt;
             &lt;select id="village" name="village"&gt;
                      &lt;option value="0"&gt;choose...&lt;/option&gt;
                  &lt;/select&gt;
             &lt;br /&gt;&lt;br/&gt;
             Search By Specialization:&lt;br /&gt;
             &lt;select name="specialization"&gt;
               &lt;option id="0" disabled="disabled"&gt;-- select Job --&lt;/option&gt;
  
            &lt;?php specializationQuery(); ?&gt;
            &lt;/select&gt;
            &lt;input type="submit" name="search" value="Search"  /&gt;
          &lt;/form&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php require_once('footer.php'); ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>