我有以下代码:
try
{
$sql = 'SELECT id, type, date, amount, description, category
FROM `transactions`
WHERE type = "income"
AND month(date) = '$monthselect'
ORDER BY `transactions`.`id` DESC
LIMIT 0,50';
$result2 = $pdo->query($sql);
}
现在,我想给这个month(Date)
变量我想选择哪个月份。如果我输入 1,它将给我一月。所以我想,如果我用1定义一个变量,我可以用它来选择一个月,对吧?
$monthselect = 1;
它不起作用。我究竟做错了什么?