dongwenghe2416 2013-04-26 19:24
浏览 35
已采纳

php mysql从数据库中检索上传的照片

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?

Until now I started with the query of the search by name:

search.php

<?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'<option value="' . $record['user_name'] .  '">' . $record['user_name'] . '</option>';

  }

}



// function for select by specialization

function specializationQuery(){

$specData = mysql_query("SELECT * FROM specialization");

  while($recordJob = mysql_fetch_array($specData)){

     echo'<option value="' . $recordJob['specialization_name'] .  '">' . $recordJob['specialization_name'] . '</option>';

  }


}

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 "<ul>
          <li>
           ".$firstname. " ".$lastname ."
          </li>
          <li>
           <img style='width:80px' src='".$profile_pic . "'>
          </li>
         </ul>";
     }
   }
   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 "<ul>
          <li>
           ".$firstname. " ".$lastname ."
          </li>
          <li>
           <img style='width:80px' src='".$profile_pic . "'>
          </li>
         </ul>";
     }
   }
   else
   {
       echo "their was no result!!!!";
   }

}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>search page</title>
<link href="style/stylesheet.css" rel="stylesheet" type="text/css" />
<script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript">

 $(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("<option>wait...</option>");
                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("<option>wait...</option>");
            $.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');

            });
    });


</script>
</head>


<body>
<div class="container">
<!--<?php require_once('header.php'); ?>-->
<br />
<br />
<br />
<br />

  <!-- <?php require_once('leftsideBar2.php'); ?>-->


   <div id="search-title">Search section</div>
    <div id="search-form">
    <?php include "select.class.php"; ?>
        <form action="search.php" method="post">

         Search By Name:<br />
         <select name="name" >
            <?php nameQuery(); ?>
             <option id="0">-- select By UserName --</option>
             </select>
           <br/><br/>
           Search By Governorate:<br />

        <select id="governorate" name = 'governorate'>
                <?php echo $opt->ShowGovernorate(); ?>
                </select>
           <br /><br/>
           Search by District:<br />

      <select id="district" name="district">
                    <option value="0">choose...</option>
                </select>

           <br /><br/>
           Search by Cities:<br />
           <select id="village" name="village">
                    <option value="0">choose...</option>
                </select>
           <br /><br/>
           Search By Specialization:<br />
           <select name="specialization">
             <option id="0" disabled="disabled">-- select Job --</option>

          <?php specializationQuery(); ?>
          </select>
          <input type="submit" name="search" value="Search"  />
        </form>

    </div>
</div>
<?php require_once('footer.php'); ?>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • dongritan5654 2013-04-26 19:29
    关注
       echo "<ul>
              <li>
               ".$firstname. " ".$lastname ."
              </li>
              <li>
               <img src='".$profile_pic . "'>
              </li>
             </ul>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料