dqu92800 2014-10-29 23:23
浏览 20
已采纳

无法从日期列中检索日期 - PHP Mysql

Hi i am beginner in php, and i am try to retrieve the datas(between two dates from single column namely booking) from the table(billing_details) using the date column

below is the source code

$from = mysql_real_escape_string($_POST['from']);
$to = mysql_real_escape_string($_POST['to']);
$from = date("d-m-Y", strtotime($from));
$to = date("d-m-Y", strtotime($to));

echo $from; 

$sql = mysql_query("select * from billing_details where SRF ='$_POST[srf]' or Service_Type ='$_POST[service]' or Status ='$_POST[status]' or Branch ='$_POST[branch]' or DATE(`Booking`) between '".$from."' and '".$to."'");

 ![I have select two different dates to get datas between the selected dates , but nothing is retrieved, only the echo $from is retrieved the the selected date][1]


Kindly help me to solve this issue, Thanks in advance

Regards,
Abdul hameed
  • 写回答

3条回答 默认 最新

  • dousigan0499 2014-10-29 23:33
    关注

    Your date format is incorrect and should instead be 'Y-m-d' or else mysql will not recognize it. Learn get used to that format :)

    Also since you are a beginner be aware that you should check the strtotime return. Of it evaluates to false then the input is invalid and passing that to the date() function would result in 1969-12-31 i believe

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部