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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度