Forum Moderators: coopster
So I have this script that figures out the dates between two dates:
(the strtotime donīt know if correct, I added it trying to take the mysql format in the variable.)
//start date 2004-12-10
$sm=12;
$sd=10;
$sy=2004;
//end date 2004-12-14
$em=12;
$ed=14;
$ey=2004;
//utc of start and end dates
$s=mktime(0,0,0,$sm, $sd, $sy);
$e=mktime(0,0,0,$em, $ed, $ey);
while($s<=$e){
print date('Y-m-d',$s).","; //display date in mySQL format
(strtotime ("%Y-%m-%d",$s=$s+86400)); //increment date by 86400 seconds(1 day)
Then the problem, how to update all the columns that have the dates I just received?
The update would be like this:
$sql = mysql_query("UPDATE `disponibilidad` SET `$s` = 'z' WHERE `property` = 'Banana_Beach_3' ");
I need to put all dates into the variable $s in the query.
In mysql I have an table with dates as name of the columns with an value, so
now I need to update all columns with same name as the dates I got in the loop.
This needs to be done automatically,
so the query must be:
$sql = mysql_query("UPDATE `disponibilidad` SET `$s` = 'z' WHERE `property` = 'Banana_Beach_3' ");
Now I think I am stupid, that putting the query inside the loop like this:
while($s<=$e){
etc,
here the update query
}
and that would do it....?
I tried it but I do think the format is wrong with the dates, need to be converted to mysql format date #*$!x-xx-xx