dqu92800 2014-10-30 07: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-30 07: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条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)