duanchique1196 2015-10-21 06:27
浏览 21
已采纳

如何使用php获取mysql上周的条目

there is table in data base as P_order now i want fetch the last one weeks entry in that data base.... as i fetched the entry of the present date....but not able to fetch the last one week entry...

 <?php

 $wherecat = "`p_order_status` = 'active' AND `p_order_date` LIKE '".date('Y-m-d')."%' ";
 $catsql =$general->GetRows('*' ,'p_order' ,$wherecat);
 $catRes = mysql_num_rows($catsql);
 ?>
<p><?=$catRes;?></p>

<div class="box1">
    <span class="li_cloud"></span>
    <h3>Order Placed in Last Week</h3>
</div>
<?php

 $wherecat1 = "`p_order_status` = 'active' AND `p_order_date` LIKE '".date('Y-m-d',strtotime('-1 day')). "%' ";
 $catsql1 =$general->GetRows('*' ,'p_order' ,$wherecat1);
 $catRes1 = mysql_num_rows($catsql1);
 ?>

<p><?=$catRes1;?></p>
  • 写回答

3条回答 默认 最新

  • douciping4283 2015-10-21 06:42
    关注
    SELECT * FROM p_order WHERE date(p_order_date) > DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
    

    or

    $wherecat1 = "`p_order_status` = 'active' AND date(`p_order_date`) > DATE_SUB(CURDATE(), INTERVAL 1 WEEK)";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?