Forum Moderators: coopster
$date_start=date("Y-n-d",$array{"sun"}{0});
$date_end=date("Y-n-d",$array{"sun"}{0}+6*24*60*60);
$query="SELECT * FROM `calendar` WHERE 1 AND `date` >= '".$date_start."' AND `date` <= '".$date_end."' ORDER BY `date` ASC";
$result=mysql_query($query);
[edited by: jatar_k at 5:50 pm (utc) on Nov. 8, 2004]
[edit reason] linked it up [/edit]
I didn't manage to find any information about what $array{"sun"}{0} means from your link, so i tried the following method:
<?php$timenow = "NOW()";
$oneweeklater = "NOW() - INTERVAL 7 DAY)";
$week = "SELECT *, date_format(calendar_events.StartTime, '%l:%i%p')as starttime, date_format(calendar_events.EndTime, '%l:%i%p') as endtime
FROM calendar_events
WHERE 1 AND StartTime >= '" . $timenow . "'
AND StartTime <= '" . $oneweeklater . "';
$thisweek = mysql_query($week);
while ($w = mysql_fetch_assoc($thisweek))
{echo "$w[starttime]";
echo "$w[endtime]";}
?>
Apparently there is an unexpected T_variable at the echo lines, but i suspect the problem is to do with the query. Don't know what's wrong with it though! Can anyone help...?
Would also be grateful if someone would tell me what the WHERE 1 part means. Thanks!
Added: i think the last two lines of that block could just be:
WHERE 1 AND StartTime >= $timenow
AND StartTime <= $oneweeklater[b]"[/b]; Correct me if i'm wrong - i'm not having a very clear thinking day today :)
$startyear = "date_format(calendar_events.StartTime, '%Y-%m-%d')";
$week = "SELECT *, date_format(calendar_events.StartTime, '%l:%i%p') as starttime, date_format(calendar_events.EndTime, '%l:%i%p') as endtime,
date_format(calendar_events.StartTime, '%a, %e %b:') as eventdate
FROM calendar_events
WHERE $startyear >= NOW()
AND $startyear <= DATE_ADD(NOW(), INTERVAL 7 DAY)
ORDER BY StartTime";
$thisweek = mysql_query($week);
while ($w = mysql_fetch_array ($thisweek)) {
echo "$w[eventdate] <br />";
echo "Start:" . "$w[starttime] <br />";
echo "Finish:" . "$w[endtime] <br /> <br />";}