PHP / MySQL图像检索和显示由用户定义的位置和时间

时间:2016-10-21 18:06:44

标签: php mysql image data-retrieval

我尝试做的是编写一个PHP搜索页面,该页面将通过MySQL数据库检索用户上传的图像,其中图像通过引用存储,搜索可以由用户完成,地点和日期。也就是说,登记为来自特定城市,状态和邮政编码的用户给出图像的位置和日期,然后将其存储在文件夹中,然后可以按用户,位置和日期搜索图像。搜索结果显示在ASPX页面中。

到目前为止,我已经获得了以下代码。现在,results.aspx页面只显示小红色X&#39。

search_locations.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<title>Search Images</title>



<style type="text/css" media="screen">
ul li{
  list-style-type:none;
}
</style>
</head>

<body>
<h3>Search Locations</h3>
<p>You may search either by city, state/province or postal code</p>
<form method="post"  action="../search.aspx?go" id="searchform">
<label id="city">City</label>
<input type="text" name="city">
<label id="state">State or Province</label>
<input type="text" name="state">
<label id="postcode">Zip (Postal) Code</label>
<input type="text" name="postcode">

<fieldset name="Date">
<legend>Date</legend>

                <legend>Month</legend>

                <select name="Month">
                <option>January</option>
                <option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<legend>Day</legend>
<input type="text" name="day">          
<legend>Year</legend>
<p>20<input type="text" name="year"></p>
            </select>

</fieldset>
<?php
if(isset($_REQUEST['submit'])){

    $s = $_REQUEST['search'];
    mysql_connect("localhost","root","")or die(mysql_error());
    mysql_select_db("userdata") or die(mysql_error());
    $sql ="select image from userdata where image= '%".$s."%' ";

    $result = mysql_query($sql) or die(mysql_error());
    $count = mysql_num_rows($result);

    if($count != 0){
        while($row = mysql_fetch_array($result)){
      echo $row['firstname'].'<br>';
      echo $row['lastname'].'<br>'; 
      echo $row['city'].'<br>';
      echo $row['state'].'<br>';    
          echo $row['country'].'<br>';  
          echo $row['image'].'<br>';
          echo $row['imagetime'];

        }
    }
    else{
      echo 'Error Message';
    }
}



?>


<input type="submit" name="submit" value="Search">

</form>




</body>
</html>

userdata.sql

INSERT INTO `userdata` (`id`,`firstname`,`lastname`,`email`,`phone`,`state`,`city`,`postcode`,`country`,`gender`,`dob`,`image`,`imagetime`) VALUES (NULL,'Joseph','Blow','jblow@yo.com','909-555-1234','California','San Bernardino','92407','USA','M','01011990','../upload/jblow/jblowdate1.jpg','02142016');
INSERT INTO `userdata` (`id`,`firstname`,`lastname`,`email`,`phone`,`state`,`city`,`postcode`,`country`,`gender`,`dob`,`image`,`imagetime`) VALUES (NULL,'Helena','Noe','helnoe@yo.com','909-555-5678','California','San Bernardino','92407','USA','F','02021990','../upload/hnoe/helnodate1.jpg','06012016');

search.aspx

Search Results
<br/>
<br/>
<img src="upload/<?php echo $row['image']; ?>">
<br/>

<img src="getImage.php" width="175" height="200"/>

有人想帮我解决这个问题吗?

0 个答案:

没有答案