Php 上下月报告
我有一张桌子,上面有日期、时间、地点和文字 现在它将报告当前的年度和月份 我试图创建3个按钮,将从数据库创建报告Php 上下月报告,php,mysql,sql,date,Php,Mysql,Sql,Date,我有一张桌子,上面有日期、时间、地点和文字 现在它将报告当前的年度和月份 我试图创建3个按钮,将从数据库创建报告 按钮将报告上个月 按钮将报告实际月份 按钮将在下个月报告 但问题是,当我单击上一个月或下一个月时,它将只报告本月的上一个月和下一个月。所以我在寻找某种跟踪日期的方法 示例: 三月(当前)->(按下下个月按钮)=四月->(按下下个月按钮)=五月。。。等 三月(当前)->(按下上个月按钮)=二月->(按下上个月按钮)=一月 +如果在下个月报告2013年12月时按下,则必须是1月的新年 +
+如果在下个月报告2013年12月时按下,则必须是1月的新年
+向后时的相同条件(2014年1月->(上一个按钮)=2013年12月)
有什么办法吗
选择hlavni.datum\u expirace、hlavni.priloha、hlavni.nazev、vedle.misto
来自赫拉夫尼
hlavni.sekce=vedle.idecko上的内部连接vedle,其中vedle.idecko位于(6,7,8,15,14,
16、17)和年份(基准面到期)=年份(当前日期())和月份(基准面到期)=
月(CURDATE())由'hlavni`.'datum_expirace`ASC,'hlavni`.'priloha`ASC')订购;
查看以下登录:您可以尝试修改:
您可以将其用作参考:
take one hidden field store in it current date:
<input type="hidden" name="date" value="<?php echo date('Y-m-01'); ?>" />
If you click On any of your three option pass type of it at submit time.
Now when you submit for Next,Previous,Current Month you need to check:
if ($_POST['type'] == 'previous')
{
$date = date('Y-m-d', strtotime("-1 month", strtotime($_POST['date'])));
} else if ($_POST['type'] == 'next') {
$date = date('Y-m-d', strtotime("+1 month", strtotime($_POST['date'])));
} else {
$date = $_POST['date'];
}
$start_date = date('Y-m-d', strtotime("-1 year", strtotime('+1 month', strtotime($date))));
$end_date = date('Y-m-01', strtotime($date));
$end_date = date('Y-m-d', strtotime('-1 second', strtotime('+1 month', strtotime($matrix_e_date_no))));
$loop_start_date = strtotime($start_date);
$loop_end_date = strtotime($end_date);
while ($loop_start_date < $loop_end_date) {
//Print your html content here
$loop_start_date = strtotime(date('Y-m-d', strtotime('+1 month', $loop_start_date)));
}
$set_date_again_in_hidden_field = date('Y-m-01', strtotime($date));
将一个隐藏字段存储在当前日期中:
您可以使用以下命令
假设日期格式为yyyy mm dd
上个月
从表中选择*,其中月份(创建日期)=月份(创建日期-间隔1个月)
下个月
从表中选择*月(创建日期)=月(创建日期+间隔1个月)不使用月(CURDATE())但是,将所需月份作为参数传递给查询。对不起,我不明白。我对这件事还是新手^^。你能给我解释一下你的意思吗?你使用AJAX调用吗?我仍然无法使它进入功能状态:/你只需要专注于这段代码,尝试理解,并进行必要的更改。我请求你给我一个提示^^我还是mysql的新手