Hi all,
Well I was doing fine until I decided I need a date range rather than just selecting a month and year.
I have 4 drop down menus.
beginning "month" + "year" and End "month" and "year"
my code for this:
//Get beginning report date
$firstrepyear=$_POST['firstreport_year'];
if (isset($firstrepyear) && $firstrepyear !=="") {
$firstpostyear = $firstrepyear;
}
else $firstpostyear = "2010";
$firstrepmonth=$_POST['firstreport_month'];
if (isset($firstrepmonth) && $firstrepmonth !=="") {
$firstpostmonth = $firstrepmonth;
}
else $firstpostmonth = "";
//Get end of report date
$secondrepyear=$_POST['secondreport_year'];
if (isset($secondrepyear) && $secondrepyear !=="") {
$secondpostyear = $secondrepyear;
}
else $secondpostyear = "2010";
$secondrepmonth=$_POST['secondreport_month'];
if (isset($secondrepmonth) && $secondrepmonth !=="") {
$secondpostmonth = $secondrepmonth;
}
else $secondpostmonth = "";
I am stuck on the query.
For a single month and year selection, I got this far:
$rep_e_query = ("select category, SUM(amount) as Etotal from expenses where UserID='$owner_rows' and year(date_purchased)='$postyear' and month(date_purchased)='$postmonth' GROUP BY category")or die(mysql_error());
$rep_e_result = mysql_query($rep_e_query)or die(mysql_error());
I don't know how to implement a date/between statement here.
I think I could do it if it was a static date like between 201005 and 201006 but I am confused in implementing the dynamic date into the existing query.
Any help would be appreciated,
thanks
Tin