It needs to show
Month
Date - Gig Description
Date - Gig Description
Date - Gig Description
Next Month
Date - Gig Description
Date - Gig Description
Date - Gig Description
I'm storing the date in my MySQL DB as yyyymmdd format.
Currently I've got it running 12 MySQL queries, like this:
Code: Select all
<?php
$curmonth = date("n");
$endmonth = date("n")+12; // SHOWS THE NEXT 12 MONTHS;
for($i = $curmonth; $i < $endmonth; $i++){
$tempmonth = $i;
if ($tempmonth > 12){$tempmonth = $tempmonth-12;}; // IF PAST DEC, GO BACK 12 MONTHS
if (!$curyear){$curyear=date("Y");};
// ASSEMBLE SQL QUERY
$pquery = "select * from gigs where ";
//THIS PULLS GIGS THAT ARE ONLY IN THE CURRENT MONTH RANGE
if ($tempmonth == 12){
$pquery .= 'gigdate >= "'.$curyear.(sprintf('%02d',$tempmonth)).'01" AND gigdate < "'.($curyear+1).'0101"';
}else{
$pquery .= 'gigdate >= "'.$curyear.(sprintf('%02d',$tempmonth)).'01" AND gigdate < "'.$curyear.(sprintf('%02d',$tempmonth+1)).'01"';
}
$pquery .= " ORDER BY gigdate ASC";
// Send the query to MySQL for execution
if ($numrows > 0){
// DISPLAY EACH GIG FOR THIS MONTH
}
if ($tempmonth > 11){ //GO TO NEXT YEAR IF FINISHED DECEMBER
$curyear++; //START NEXT YEAR
}
}
?>