我正在使用此功能创建数月和年份的下拉列表,我的问题是收到如下错误:
'where子句'中的未知列'格式'
下面是任何人帮助摆脱此错误的代码
date_condition = ' and 1=1 ';
if($date_type==1)
{
$date_condition = ' and m.submittimestamp BETWEEN DATE_SUB(NOW(), INTERVAL 300 DAY) AND NOW() ';
}
else if($date_type==2)
{
$date_condition = ' and YEAR(m.submittimestamp) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) and MONTH(m.submittimestamp)=MONTH(CURRENT_DATE - INTERVAL 1 MONTH) ';
}
else if($date_type==3)
{
$date_condition = ' and YEAR(m.submittimestamp) = YEAR(date(format)) AND MONTH(m.submittimestamp)=MONTH(date) ';
}
条件1和2工作正常但条件3正在出错
下面是下拉列表和脚本
<div class="form-group ">
<input name="filter_options"
<?php echo $option3; ?>
value="3" onchange="toggleDate(1)" type="radio" class="form-control" id="from_date">
<label for="from_date">show status for the month of </label>
<select name="month" class="form-control">
<?php
for ($i = 0; $i <= 12; ++$i) {
$time = strtotime(sprintf('-%d months', $i));
$value = date('m', $time);
$label = date('F ', $time);
printf('<option value="%s">%s</option>', $value, $label);
}
?>
</select>
<select name="year" class="form-control">
<?php
for ($i = 0; $i <= 12; ++$i) {
$time = strtotime(sprintf('-%d years', $i));
$value = date('Y', $time);
$label = date('Y ', $time);
printf('<option value="%s">%s</option>', $value, $label);
}
?>
<option value=" ">year</option>
</select>
</div>
答案 0 :(得分:0)
错误告诉您需要知道的一切,您有语法错误。删除错误中注明的代码开头的字母“e”。
e) AND MONTH(m.submittimestamp)=MONTH(date) GROUP
应该是
) AND MONTH(m.submittimestamp)=MONTH(date) GROUP