根据日期在数据表中搜索功能


Search function in data table based on date

我有一个数据表,我试图添加基于日期的搜索功能,但我无法获得结果,这是我的代码:

<form action="search.php" id="searchform" method="POST" class="searchbox-container">
<input type="text" id="searchbox" placeholder="Search" name="searchbox" class="searchbox" />
    <input type="datetime-local" name="date">
    <select name="select" id="select">
    <option value="type">Type</option>
    <option value="name">Name</option>
</select>
    <input type="submit" name="search" class="searchbox-btn" value="Go" />
 </form>
 <?php

此处连接:

$date=$_POST['date'];

         if($_POST['select']=="type"){
        $sqlcommand="SELECT * FROM eventform WHERE event_type LIKE '%$search%'";    

        }
        elseif($_POST['select']=="name"){
        $sqlcommand="SELECT * FROM eventform WHERE event_name LIKE '%$search%'";        

        }
        else {
            if($date!=0)
              $sqlcommand="SELECT * FROM eventform WHERE start_date LIKE '$date'";  

        }
          $sqldata=mysqli_query($con,$sqlcommand)
          or die("Error Getting Data");
          $count=mysqli_num_rows($sqldata);
          if($count!=0){
                  echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
            echo "<tr bgcolor=#555555 style=font-size:18px align=center><th>Event Code</th><th>Event Name</th><th>Event Type</th><th>Event Level</th><th>Start Date</th>
      <th>End Date</th><th>Point</th><th>Picture</th><th>Video</th><th>Description</th></tr>";
            while($row=mysqli_fetch_array($sqldata)){
            echo "<tr align=center><td>";
              echo $row['event_code'];
              echo "</td><td>";
              echo $row['event_name'];
              echo "</td><td>";
              echo $row['event_type'];
              echo "</td><td>";
              echo $row['event_level'];
              echo "</td><td>";
              echo $row['start_date'];
              echo "</td><td>";
              echo $row['end_date'];
              echo "</td><td>";
              echo $row['points'];
              echo "</td><td>";
              echo $row['pic'];
              echo "</td><td>";
              echo $row['video'];
              echo "</td><td>";
              echo $row['description'];
              echo "</td></tr>";
              }
  echo "</table>";

当我根据事件的类型和名称搜索时,我会得到结果,但当我想根据日期和时间搜索时,它根本不起作用。

日期字段的格式是什么,是时间戳?对于时间戳,执行:

$sqlcommand="SELECT * FROM eventform WHERE start_date > '".$date."' ORDER BY start_date DESC";

OR日期yy-mm-dd格式,仅:

$sqlcommand="SELECT * FROM eventform WHERE start_date = '".$date."' ORDER BY start_date DESC";