简体   繁体   English

时间戳的下拉列表-从数据库检索图像(基于时间戳where子句的查询)-php / mysql

[英]dropdown list of timestamp- retrieving image from database (query based on timestamp where clause)-php/mysql

1.The Drop down list- lists the timestamp duration at which the images where put into database 1.下拉列表-列出将图像放入数据库的时间戳记持续时间

  1. To view a image, user selects the timestamp displayed in the drop down list and clicks submit 要查看图像,用户选择下拉列表中显示的时间戳,然后单击提交。

  2. As soon as the submit button is pressed, "Connect.php" connects to database, makes "select" query comparing the timestamp in database to the timestamp user as selected 按下提交按钮后,“ Connect.php”将连接到数据库,并进行“选择”查询,将数据库中的时间戳与选定的时间戳用户进行比较

BUT I KEEP GETTING ERROR AS INVALID QUERY: You have an error in your SQL syntax; 但是我会继续以无效查询的方式获取错误:您的SQL语法有错误; check the manual that corresponds to your MariaDB server version for the right syntax to use near '19:21:43' at line 1 检查与您的MariaDB服务器版本相对应的手册,以在第1行的'19:21:43'附近使用正确的语法

DATABASE TABLE HAS 数据库表已

1 "time_stamp" -datetime- CURRENT_TIMESTAMP 1个“ time_stamp” -datetime- CURRENT_TIMESTAMP

2 "name" - varchar(200) 2个“名称”-varchar(200)

3 "images"- longblob 3张“图片”-longblob

kindly see the code and correct me 请查看代码并纠正我

index.php 的index.php

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
$conn=mysql_connect("localhost","root","");
mysql_select_db("simpletest",$conn);
$qry= "select * from indu";
$result=mysql_query($qry,$conn);
$options="";
while($row=mysql_fetch_array($result))
{
    $options = $options."<option> $row[0] </option>";
}

?>
</head>

<body>
<form action="connect.php" method="post">
 <select name="selected">
 <?php echo $options; ?>
 </select>
 <input type="submit" name="submit" value="submit" />
 </form>
</body>
</html>

connect.php connect.php

<?php 
$connn=mysql_connect("localhost","root","");
mysql_select_db("simpletest",$connn);
if (isset($_POST['submit']))
{
    $v1=$_POST['selected'];
    echo $v1;
    echo "<br/>";
    $qrry= "select * from indu where 'time_stamp'=$v1";
    echo $qrry;
    $result1=mysql_query($qrry,$connn);
    echo $result1;
    if (!$result1) 
    { 
      die('Invalid query: ' . mysql_error());
     }
    while($row1=mysql_fetch_array($result1))
    {
    echo '<img height"300" width="300" src="data:image;base64,'.$row1[1].'"/>';
    }
}
?>

You do not have value in <option value=""> . 您在<option value="">没有值。 You need something like this: 您需要这样的东西:

 $options = $options."<option value=\"$row[0]\"> $row[0] </option>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM