Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将日期字段设置为3个月前_Php_Mysql - Fatal编程技术网

Php 如何将日期字段设置为3个月前

Php 如何将日期字段设置为3个月前,php,mysql,Php,Mysql,我使用单选按钮从数据库中获取过去3个月的记录。我使用一个单选按钮为用户选择日期范围,三个月前。 如何将单选按钮的值设置为大约3个月前 <input type="radio" id="test7" name="thismonth" value="<?php echo date("Y-m", strtotime("-3 months"));?>" /> 像这样尝试: <?$effectiveDate=date('y-m-d'); $effectiveDate = s

我使用单选按钮从数据库中获取过去3个月的记录。我使用一个单选按钮为用户选择日期范围,三个月前。 如何将单选按钮的值设置为大约3个月前

 <input type="radio" id="test7" name="thismonth" value="<?php echo date("Y-m", strtotime("-3 months"));?>" />
像这样尝试:

<?$effectiveDate=date('y-m-d');
$effectiveDate = strtotime("-3 months", strtotime($effectiveDate)); ?>
<input type="radio" id="test7" name="thismonth" value="<?php echo effectiveDate?>" />


我在你的代码中没有看到访问你数据库的尝试…@Akhil,这个问题看起来像MySQL部分,但你正在显示HTMLI,请确认有没有办法设置单选按钮从前3个月到本月的值?问题在你的查询中,告诉我们你的查询这是一种创建查询的危险方式。请使用准备好的语句/参数化查询。@Christiaan这只是为了演示,让他理解。
<?$effectiveDate=date('y-m-d');
$effectiveDate = strtotime("-3 months", strtotime($effectiveDate)); ?>
<input type="radio" id="test7" name="thismonth" value="<?php echo effectiveDate?>" />