0
In the BD table I have a column "day" type "date" keeping "yyyy-mm-dd", I’m trying to make a query that returns me the current month, I’ve tried many ways and nothing.
<?php session_start();
date_default_timezone_set('America/Sao_Paulo');
$d = date('d');
$m = date('m');
$y = date('Y');
$query_cx = "SELECT dia FROM caixa WHERE MONTH(data)='$m' ORDER BY id DESC";
$result_cx = mysqli_query($conectar, $query_cx);
while ($linhas_cx = mysqli_fetch_assoc($result_cx)){
echo "$linhas_cx['valor'];
}
?>
the second part are doubts, thinking that the year is ending and that this consultation will always return me the current month;
1- this consultation will end up returning me the current month and the same month of the previous year?
2- as I would do to search some previous month if the year will be different?
– Marlysson