luca - 2007-09-11 08:40:44
hi!
i made some corrections to write.php file.
it didn't work properly with dates among more than one month (ex. 2007-09-10 2007-11-09)
i used a call to this recursive function:
function query($datainizio,$datafine,$data3,$data2)
{
$date = explode("-", $datainizio) ;
$date1 = explode("-",$datafine);
$start = mktime(0,0,0,intval($date[1]),intval($date[2]),intval($date[0]),0);
$end = mktime(0,0,0,intval($date1[1]),intval($date1[2]),intval($date1[0]),0);
if(intval($date[1]) == intval($date1[1])) //same month
{
$nbrDays = ($end - $start)/(60*60*24);
$query = "INSERT INTO `portable` (`Name` , `DateBorrow` , `NbrDays` , `Username` ) VALUES ('$data2', '$datainizio', '$nbrDays', '$data3');" ;
include("./config.inc");
$result = mysql_query($query, $db);
if ($result == false)
die("Failed " . $query);
/*
else
$page->Bold("Insert done correctly !!!!") ;
*/
//print $query."<br>";
}
else //different month
{
$lastDay = date("t",$start)+1;
query($datainizio,$date[0]."-".$date[1]."-".$lastDay,$data3,$data2);
$date[1] = intval($date[1])+1;
query($date1[0]."-".$date[1]."-01",$datafine,$data3,$data2);
}
}
sorry if i used some Italian names for variables, $datainizio means "start date" and $datafine means "end date"
i think it's a more readeble code and...it works properly ;)
Alf, feel free to contact me if you liked this solution (cxrnvs@email.it)