我想显示每个月的数据。考虑今天2018-04-11开始的月开始,到2018-05-11结束,所以在我们要添加的任何产品之间我想要显示它们。
以下是我正在使用的查询:
$curYear = date('Y-m', time());
$MonthendDate = '11';
$MonthEnd = $curYear.'-'.$MonthendDate;
$today= date('Y-m-d');
$select_agent = mysqli_query($conn,"SELECT *
FROM disbursal_amt as D
INNER JOIN customer_details as c
WHERE (D.da_cid = c.cid)
AND (D.da_bt_id = '".$_POST["employee_id"]."')
AND (D.da_date BETWEEN '$MonthEnd' AND '$today') ");
但我只通过上述查询获得当前月份数据。
产品将在每日基础上添加,并且仅在该月产生。
请帮帮我。
答案 0 :(得分:0)
不确定你的$ monthEnd,你可以试试
// One month from today
$monthEnd = date('Y-m-d', strtotime('+1 month'));
$today=date('Y-m-d');
SELECT * FROM disbursal_amt as D
INNER JOIN customer_details as c
WHERE (D.da_cid = c.cid)
AND (D.da_bt_id = '".$_POST["employee_id"]."')
AND (D.da_date BETWEEN '$today' AND '$monthEnd')
警告:您的脚本对SQL Injection Attack开放 甚至if you are escaping inputs, its not safe! 使用prepared parameterized statements