I'm attempting to group information in a SQL Database (Using MYSQL) through a php script. Here's my function that I wrote. (Today is my first day with php, technically second)
function getQuery($ResultType, $tbl_name, $Date) {
if($ResultType == 'Day') { return "SELECT * FROM $tbl_name where Date($tbl_name.Date) = DATE('$Date')"; }
if($ResultType == 'Year') { return "SELECT * FROM $tbl_name where Year($tbl_name.Date) = Year('$Date')" ; }
if($ResultType == 'Month') { return "SELECT * FROM $tbl_name where Year($tbl_name.Date) = Year('$Date') and Month($tbl_name.Date) = Month($Date)"; }
}
When trying to get the data by "Day" or "Year" it works, but the query that is trying to select everything for that month is returning 0 rows.
Date is formatted as yyyy-mm-dd if it matters.