kb9yjg Posted November 18, 2008 Share Posted November 18, 2008 Hello all, I have a script that at current shows the dates in the week starting with monday. It also shows incremented times starting from midnight to 11:30pm incremented every 30 minutes. What I am trying to do is dynamically add cells with spaces where there is no data and the event data where events are supposed to be. For example if an event is set for the 22dn at 12pm I am looking to place the link at the 22nd at noon. Below is the code. You can see the output at www.bitsonline.us/jevent/index.php <? 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); $q="select * from $table group by evday order by evday asc"; $result=mysql_query($q) or die("Error getting events: ".mysql_error()); for($a=0, $eTime=strtotime($row[evtime]); $a<$timeblock; $a++, $eTime=strtotime("+$bloxklength minutes",$eTime)){ $totevtime=date("H:i",$eTime); } if($weekDay == 0){ $tempTimestamp += $oneDay; }else{ $tempTimestamp -= $weekDay * $oneDay; } $currentcol=1; echo '<table border="1" cellspacing="1">'; echo '<tr>'; echo '<td rowspan="49" align="center">'; // time table starts 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>'; for($i=0;$i<$maxcols;$i++){ $tempTimestamp += $oneDay; $weekDate = date("Y-m-d", $tempTimestamp); echo '<th>'.$weekDate.'</th>'; } echo '</tr>'; // auto advancing date headers end here in mysql format //get event data start while($row=mysql_fetch_assoc($result)){ $details=$row['event'].' '; $details.=$row['evday'].' @ '.$row['evtime'].' '; $details.=$row['about']; if($currentcol=1){ echo '<tr>'; } for ($col=0; $col<$maxcols; $col++) { $currentcol++; echo '<td align="center"><a href="#" title="'.$details.'">'.$row['event'].'</a></td>'; } } echo "</tr>"; if($currentcol>$maxcols){ echo '</tr>'; } // get event data end echo '</table>'; ?> Any help would be greatly appreciated. Sincerely; KB9YJG Link to comment https://forums.phpfreaks.com/topic/133220-need-help-with-positioning-data-in-specific-table-cells/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.