I couldn't get this working. I wrote the following function:
PHP Code:
function getPublishDate()
{
$Y=date("Y");
$M=date("n");
$D=date("j");
$dayCount=7;
$tempDay=0;
$w=settype($tempDay,"integer");
$dateArray[]="";
$r=0;
while($dayCount>=0)
{
$tempDate="";
if($D<=$dayCount)
{
$tempMonth=$M-1;
if($tempMonth=='2'||$tempMonth=='4'||$tempMonth=='6'||$tempMonth=='9'||$tempMonth=='11')
{
if($tempMonth=='2')
{
if($Y=="2004"||$Y=="2008") //leap years
{
$tempDay=$D-$dayCount;
$tempDay=29+$tempDay;
}
else
{
$tempDay=$D-$dayCount;
$tempDay=28+$tempDay;
}
}
else
{
$tempDay=$D-$dayCount;
$tempDay=30+$tempDay;
}
$tempYear=$Y;
}
else
{
$tempDay=$D-$dayCount;
$tempDay=31+$tempDay;
if($tempMonth=='0')
{
$tempMonth=12;
$tempYear=$Y-1;
}
else
{
$tempYear=$Y;
}
}
}
else
{
$tempDay=$D-$dayCount;
$tempMonth=$M;
$tempYear=$Y;
}
$tempDate=$tempYear;
if($tempMonth<10)
{
$tempDate=$tempDate."-0".$tempMonth."-";
}
else
{
$tempDate=$tempDate."-".$tempMonth."-";
}
if($tempDay<10)
{
$tempDate=$tempDate."0".$tempDay;
}
else
{
$tempDate=$tempDate.$tempDay;
}
$dateArray[$r]=$tempDate;
$r++;
$dayCount--;
}
$publishDates="published='$dateArray[0]' OR
published='$dateArray[1]' OR
published='$dateArray[2]' OR
published='$dateArray[3]' OR
published='$dateArray[4]' OR
published='$dateArray[5]' OR
published='$dateArray[6]' OR
published='$dateArray[7]'";
return($publishDates);
}
"$publishDates" will be used at the SELECT * FROM * WHERE ($publishDates) query.
I'm sure there is a better way to define a time period for SQL querys.
I would be interested in other solutions.
thanks
bye *heidi
Bookmarks