kb9yjg Posted November 20, 2008 Share Posted November 20, 2008 Hello, I have an event calendar that I am trying to get working. I have events appearing in the week but need them to show at the proper date and time. i.e. an event stored in the db at 12 am on 11-22 Needs to show up on the column for november 22 at noon. It seems as though I am getting events to display within the set week but need them set to the right date and time. Below is my code. You can see the output as I work on it at www.bitsonline.us/jevent/index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Untitled Document</title> </head> <body> <? include('inc/connect.inc'); $table='events'; $maxcols=7; $midnight=strtotime('12am'); $timeblock=$row['timeblock']; $blocklength=30; $start=date('Y-m-d',time()); $weekNumber = date('W',strtotime($start)); $oneDay = 24*60*60; $tempTimestamp = strtotime($start) + ($weekNumber-1)*7;-$oneDay; $weekDay = date('w', $tempTimestamp)+1; for($a=0, $eTime=strtotime($row[evtime]); $a<$timeblock; $a++, $eTime=strtotime('+$bloxklength minutes',$eTime)){ $totevtime=date('H:i',$eTime); } echo '<table border="1" cellspacing="1">'; echo '<tr>'; echo '<td rowspan="49" align="center">'; // time table starts<br /> echo '<table>'; echo '<tr>'; echo '<td><a href="javascript:onclick=window.print()">print</a></td>'; echo '</tr>'; for($x=0; $x<(24*2); $x++){ $tod=$midnight+($x * $blocklength * 60); $display=date("H:i a",$tod); if(substr($display,0,2)=='00'){ $display="12".substr($display,2); } $tag='<tr><td>'.$display.'</td></tr>'; echo $tag; } echo '</table>'; //time table ends echo '</td></tr>'; // auto advancing date headers start here in mysql format echo '<tr>'; if($weekDay == 1){ $tempTimestamp += $oneDay; }else{ $tempTimestamp -= $weekDay * $oneDay; } $currentcol=1; $wkstart=date("Y-m-d",$tempTimestamp); echo $wkstart.'<br />'; for($i=0;$i<$maxcols;$i++){ $tempTimestamp += $oneDay; $weekDate = date("Y-m-d", $tempTimestamp); echo '<th>'.$weekDate.'</th>'; } $q="select * from $table where evday between '$wkstart' and '$weekDate'"; echo $q.'<br />'; $result=mysql_query($q) or die('Error getting events: '.mysql_error()); echo '</tr>'; echo '<tr rowspan="48">'; for($currentcol=1; $currentcol<$maxcols; $currentcol++){ while($row=mysql_fetch_assoc($result)){ $details=$row['event'].' '; $details.=$row['evday'].' @ '.$row['evtime'].' '; $details.=$row['about']; $currentcol++; if($row['evtime']=$display && $row['evday']=$weekDate){ echo '<td align="center">'; echo '<a title="'.$details.'">'.$row['event'].'</a>'; echo '</td>'; } if($currentcol<$maxcols){ echo '<td align="center" rowspan="48"> </td>'; if($currentcol==$maxcols){ echo '</tr>'; } } } } if($currentcol>maxcols){ echo '</tr>'; } echo '</table>'; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/133523-help-setting-events-in-calendar-to-proper-date-and-time/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.