duanlu4371
2016-10-20 05:23
浏览 86
已采纳

SELECT * FROM dblist WHERE日期?

I have my date from my date input : 20-10-2016

echo "<form method='post' action='rapor.php'>";
echo "<input type='date' name='pickdate' value=".date("Y-m-d")."> <input type='submit' value='Git'>";
echo "</form>";

$pickeddate = strtr($_POST['pickdate'], '/', '-');
echo date('Y-m-d', strtotime($pickeddate)); 

And result of this : 2016-10-20

So far so good..

I need to show only rows date i have picked.

+------+-------------+---------------------+
| name |  mail       | dateandtime         |
+------+-------------+---------------------+
| AAA  |   a@a.com   | 2016-04-20 06:44:19 |
| BDC  |   b@c.com   | 2016-10-21 06:44:19 |
| CDD  |   c@d.com   | 2016-04-10 06:44:19 |
| EED  |   e@d.com   | 2016-10-20 06:44:19 |
| SAS  |   a@s.com   | 2016-04-10 06:44:19 |
+------+-------------+---------------------+

thats my result code but....

$result = mysql_query('SELECT * FROM dblist WHERE ('$pickeddate%')  ');

why not working?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

5条回答 默认 最新

  • dqlhsm9820 2016-10-20 05:27
    已采纳

    It should be

    $newdate = date('Y-m-d', strtotime($pickeddate)); 
    $result = mysql_query('SELECT * FROM dblist WHERE dateandtime LIKE  "'.$newdate.'%"  ');
    
    评论
    解决 无用
    打赏 举报
查看更多回答(4条)

相关推荐 更多相似问题