html网页如何通过搜索时间,找出mysql我需要的数据

我现在能通过查询指定的文字,跳转到指定的界面,但是无法通过搜索起始时间找到我需要的数据。

img


<?php
    $search = $_POST['search'];   //接收搜索框中的内容
    function skip($url,$pic,$message){
         $html=<<<A
         <!DOCTYPE html>
         <html lang="zh-CN">
         <head>
         <meta charset="utf-8" />
         <meta http-equiv="refresh" content="1;URL={$url}" />
         <title>正在跳转中</title>
         <link rel="stylesheet" type="text/css" href="style/remind.css" />
         </head>
         <body>
         <div class="notice"><span class="pic {$pic}"></span> {$message} <a href="{$url}">1秒后自动跳转中!</a></div>
         </body>
         </html>
A;
         echo $html;
         exit();
}
    switch ($search )
        {
        case "温度":
        skip('graphics/temperature.html','ok','查询成功!');
        break;
        case "湿度":
        skip('graphics/humidity.html','ok','查询成功!');
        break;
        case "光照":
        skip('graphics/light.html','ok','查询成功!');
        break;
        case "空气质量":
        skip('graphics/quality.html','ok','查询成功!');
        break;
        default:
        skip('main.html','ok','请正确输入查询条件!');
        }
?>

根据时间的话,就看你自己想要怎样的查询了,如果要查的是日期的话,假设你查询的是2021-10-14 ,那么你条件就是

select * from table  where date_format(creat_time, '%Y-%m-%d%')='2021-10-14'

  1. 起始时间作为范围查找,或者选择日期查当天
  2. 按你现在的写法,再把时间范围或者日期传递到下个页面,直接用get拼地址就行
  3. 然后在后面的页面拼到查询逻辑做查询
//我这是thinkphp框架的写法,因为我不会用原生php
$date = request()->param('date',0);  //这里的$date表示你前端传给后端的要想搜索的日期
$res = \db('数据表名')->whereDay('create_time',$date)->select();  //搜索指定日期
return $res;  //把查询到数据返回前端