creating an array of dates from start and end date
Posted: Sun Apr 06, 2003 7:06 am
I am trying to create an array of dates based on a start and end date from a MySQL record. I have the following code while the query is OK, I can not create an array. Any Ideas?
it seems the $count is always 0
Code: Select all
$query = "SELECT cal_date_start, cal_date_end
FROM cal_entry
WHERE year(cal_date_start)<='$year' AND month(cal_date_start)<='$month' AND year(cal_date_end)>='$year' AND month(cal_date_end)>='$month'";
$result = mysql_query ($query);
while($row = mysql_fetch_assoc($result))
$format='Y-m-d h:i:s';
$cal_date_start = explode('-',$row[cal_date_start]);
$syear = $date_array[0];
$smonth = $date_array[1];
$sday = $date_array[2];
$cal_date_end = explode('-',$row[cal_date_end]);
$eyear = $date_array[0];
$emonth = $date_array[1];
$eday = $date_array[2];
$cal_date_start = mktime(00,00,00,$smonth,$sday,$syear);
$cal_date_end = mktime(00,00,00,$emonth,$eday,$eyear);
while($cal_date_start < $cal_date_end) {
$cal_date_start = $cal_date_start + (24 * 3600);
$dateArray[] = date($format,$cal_date_start);}
//$dateArray[]=$row['cal_date_start'];
$count = count($dateArray);
$min = 1;
if ($count < $min) {
$dateArray[] = array('0000-00-00');
}
echo build_calendar($month,$year,$dateArray);
if (isset ($_GET['date'])) {
$date = $_GET['date'];
} else {
$date = date("d F Y");
}