Sheldon
07-15-2007, 05:58 PM
Hi, I am writing a booking system for a property to rent on a short term basis.
I am using active calendar (http://www.micronetwork.de/activecalendar/) on this site, www.langsretreat.co.nz and am trying to allow multiple dates to be booked.
I can get single dates to work but have a for each question
here is how i call the dates from the database.
$sql = "SELECT id,DATE_FORMAT(events,'%c/%e/%Y') as date1, DATE_FORMAT(evente,'%c/%e/%Y') as date2,class FROM calendar";
$query = mysql_query($sql) or die (mysql_error());
while($result = mysql_fetch_assoc($query)){
addevent($result['date1'],$result['date2'],$result['class']);
}
and here is the function 'addevent'
function addevent($startdate,$enddate,$class){
global $cal;
// Start Date.
$sdate = strtotime($startdate);
$y1 = date("Y",$sdate);
$m1 = date("m",$sdate);
$d1 = date("d",$sdate);
// End date
$edate = strtotime($enddate);
$y2 = date("Y",$edate);
$m2 = date("m",$edate);
$d2 = date("d",$edate);
foreach( /* day is less that end date and is still in calenday month */){
$cal->setEventContent($y,$m,$d,$class);
}
}
so i guess i need some help on running trough the date range and running the second function.
Does any one have any ideas on how to do this.
Thanks
I am using active calendar (http://www.micronetwork.de/activecalendar/) on this site, www.langsretreat.co.nz and am trying to allow multiple dates to be booked.
I can get single dates to work but have a for each question
here is how i call the dates from the database.
$sql = "SELECT id,DATE_FORMAT(events,'%c/%e/%Y') as date1, DATE_FORMAT(evente,'%c/%e/%Y') as date2,class FROM calendar";
$query = mysql_query($sql) or die (mysql_error());
while($result = mysql_fetch_assoc($query)){
addevent($result['date1'],$result['date2'],$result['class']);
}
and here is the function 'addevent'
function addevent($startdate,$enddate,$class){
global $cal;
// Start Date.
$sdate = strtotime($startdate);
$y1 = date("Y",$sdate);
$m1 = date("m",$sdate);
$d1 = date("d",$sdate);
// End date
$edate = strtotime($enddate);
$y2 = date("Y",$edate);
$m2 = date("m",$edate);
$d2 = date("d",$edate);
foreach( /* day is less that end date and is still in calenday month */){
$cal->setEventContent($y,$m,$d,$class);
}
}
so i guess i need some help on running trough the date range and running the second function.
Does any one have any ideas on how to do this.
Thanks