kb9yjg Posted July 23, 2008 Share Posted July 23, 2008 Hey all, I have a script that creates time increments dynamically and should be displaying columns right though Any ones help is greatly appreciated. Code is below. <? $stime = strtotime('12am'); for ($i = 0; $i < (24 * 4); $i++) { $tod = $stime + ($i * 30 * 60); $display = date('h:i A', $tod); if (substr($display, 0, 2) == '00') { $display = '12' . substr($display, 2); } include('inc/connect.inc'); $table="events"; $columns = 7; $current_column = 1; $cols=7; if ($current_column == 1) { echo '<tr><td scope=row align=center>'.$display.'</td>'; } $q="select * from $table"; $res=mysql_query($q) or die("Error selecting events. ".mysql_error()); while($row=mysql_fetch_assoc($res)){ if($display=$row['evtime']){ echo '<td align="center"><a title="'.$row['eday'].'<br />'.$row['evtime'].'<br />'.$row['about'].'">'.$row['event'].'</a></td>'; $current_column++; if ($current_column > $columns) { echo "</tr>"; $current_column = 1; }else{ echo '<td> </td>'; } }else{echo '<td> </td>';} } } if ($current_column>1) { for ($col=$current_column; $col<=$columns; $col++) { echo "<td> </td>"; } echo '</tr>'; } ?> Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/ Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 You didn't state what the problem was. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597634 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 having issues with getting things to populate correctly and look right thats why i directed you to the site address at bitsonline.vndv.com//index.php Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597860 Share on other sites More sharing options...
DarkWater Posted July 23, 2008 Share Posted July 23, 2008 You never posted the site address before your most recent post. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597863 Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 What you need to do: Describe the problem, say what it does and what you want it to do. Post any errors. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597884 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 What it does: populates each time slot with the same post it skips the date it is supposed to be posted on Does not do: does not fill in accordingly all other timeslots and columns with spaces since theres no data for those cols or slots Does not stick the time and event in the correct time slot What i want it to do. Fill in all other columns and time slots with spaces so that there are no empty cells stick the event on the correct date and time This is a weekly event calendar and need to have each column either filled with events or spaces indicating no event is scheduled. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597895 Share on other sites More sharing options...
DarkWater Posted July 23, 2008 Share Posted July 23, 2008 Yeah well, we can't help much without any code. Please post RELEVANT code inside of code tags. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597896 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 as seen on my original post of this thread <? $stime = strtotime('12am'); for ($i = 0; $i < (24 * 4); $i++) { $tod = $stime + ($i * 30 * 60); $display = date('h:i A', $tod); if (substr($display, 0, 2) == '00') { $display = '12' . substr($display, 2); } include('inc/connect.inc'); $table="events"; $columns = 7; $current_column = 1; $cols=7; if ($current_column == 1) { echo '<tr><td scope=row align=center>'.$display.'</td>'; } $q="select * from $table"; $res=mysql_query($q) or die("Error selecting events. ".mysql_error()); while($row=mysql_fetch_assoc($res)){ if($display=$row['evtime']){ echo '<td align="center"><a title="'.$row['eday'].'<br />'.$row['evtime'].'<br />'.$row['about'].'">'.$row['event'].'</a></td>'; $current_column++; if ($current_column > $columns) { echo "</tr>"; $current_column = 1; }else{ echo '<td> </td>'; } }else{echo '<td> </td>';} } } if ($current_column>1) { for ($col=$current_column; $col<=$columns; $col++) { echo "<td> </td>"; } echo '</tr>'; } ?> Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597901 Share on other sites More sharing options...
DarkWater Posted July 23, 2008 Share Posted July 23, 2008 Woops forgot about that. Can we see your DB structure? Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597902 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 Here is my table structure. I only am using a single table for this calendar. CREATE TABLE `events` ( `eid` int(11) NOT NULL auto_increment, `evtime` varchar( NOT NULL, `eday` varchar(10) NOT NULL, `event` varchar(100) NOT NULL, `about` text NOT NULL, PRIMARY KEY (`eid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597907 Share on other sites More sharing options...
DarkWater Posted July 23, 2008 Share Posted July 23, 2008 Why are you storing the date and time as VARCHAR instead of one DATETIME column which you can then manipulate? Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597910 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 stored it like that because I had some bad luck with formatting dates in previous scripts. I found if they were stored in varchar they could easily be formatted or manipulated. I am willing to learn and figure out why this isn't working though. Thank you for your time in going through this with me. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597915 Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 For a calendar type of application, using varchar is useless. You need to learn either Unix timestamps or MySQL timestamps. Don't worry too much about formatting it, that is the easy part. Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597945 Share on other sites More sharing options...
kb9yjg Posted July 23, 2008 Author Share Posted July 23, 2008 alright. Thanks for pointing me in the right direction. Now how can I get this thing fixed so it displays a link when appropriate and all cols and cells are filled with a nbsp if no event is present? Link to comment https://forums.phpfreaks.com/topic/116228-solved-nedd-assistance-with-calendar-script/#findComment-597963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.