adam291086 Posted November 30, 2007 Share Posted November 30, 2007 Hello I have a simple calendar below. How would i go about attaching it to a database and saying If theres an event change the day colour and add a link. I followed a tutorial for this and i am a little unsure. <?php // get this month and this years as an int $thismonth = ( int ) date( "m" ); $thisyear = date( "Y" ); // find out the number of days in the month $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear ); // create a calendar object $jd = cal_to_jd( CAL_GREGORIAN, date( "m" ),date( 1 ), date( "Y" ) ); // get the start day as an int (0 = Sunday, 1 = Monday, etc) $startday = jddayofweek( $jd , 0 ); // get the month as a name $monthname = jdmonthname( $jd, 1 ) ?> <table> <tr> <td colspan="7"><div align="center"><strong><?= $monthname ?></strong></div></td> </tr> <tr> <td><strong>S</strong></td> <td><strong>M</strong></td> <td><strong>T</strong></td> <td><strong>W</strong></td> <td><strong>T</strong></td> <td><strong>F</strong></td> <td><strong>S</strong></td> </tr> <tr> <?php // put render empty cells $emptycells = 0; for( $counter = 0; $counter < $startday; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } // renders the days $rowcounter = $emptycells; $numinrow = 7; for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) { $rowcounter ++; echo "\t\t<td>$counter</td>\n"; if( $rowcounter % $numinrow == 0 ) { echo "\t</tr>\n"; if( $counter < $numdaysinmonth ) { echo "\t<tr>\n"; } $rowcounter = 0; } } // clean up $numcellsleft = $numinrow - $rowcounter; if( $numcellsleft != $numinrow ) { for( $counter = 0; $counter < $numcellsleft; $counter ++ ) { echo "\t\t<td>-</td>\n"; $emptycells ++; } } ?> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/ Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 This might help http://www.phpfreaks.com/forums/index.php/topic,167842.0.html Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-402948 Share on other sites More sharing options...
adam291086 Posted November 30, 2007 Author Share Posted November 30, 2007 bump Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-402985 Share on other sites More sharing options...
adam291086 Posted December 1, 2007 Author Share Posted December 1, 2007 anyone??? Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-403857 Share on other sites More sharing options...
wsantos Posted December 1, 2007 Share Posted December 1, 2007 show us your database structure Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-403872 Share on other sites More sharing options...
adam291086 Posted December 1, 2007 Author Share Posted December 1, 2007 at the moment i just have one table with event start date event end date event discription Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-403876 Share on other sites More sharing options...
adam291086 Posted December 2, 2007 Author Share Posted December 2, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/79560-solved-calendar-help/#findComment-404309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.