Solarpitch Posted December 17, 2008 Share Posted December 17, 2008 Hey Guys, I have an application where I need to print out each date in a month and have it displayed like the below image. Just wondering what would be the best way to do this? This is as far as I got <?php function display_calendar($year) { dbconnect(); $my_info[0] = "<table> <tr> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>Sa</td> <td>Su</td> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>Sa</td> <td>Su</td> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>Sa</td> <td>Su</td> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>Sa</td> <td>Su</td> <td>M</td> <td>T</td> </tr><br />"; for ($i=1; $i<12; $i++ ) { $my_info[0] .= " <tr> "; //THIS IS THE PART I'M CONFUSED ABOUT. WOULD NEED TO LOOP THROUGH EACH MONTH AND RETURN THE DATES BASED ON THE YEAR $my_info[0] .= "<td></td>"; } $my_info[0] .= "</tr></table><br />"; return $my_info; } ?> Link to comment https://forums.phpfreaks.com/topic/137387-need-to-print-out-dates-in-a-month-example-shown/ Share on other sites More sharing options...
phpian Posted December 17, 2008 Share Posted December 17, 2008 loop throught the days 1-31 and use the checkdate function to determine if the day should be outputted or not. http://uk.php.net/checkdate Link to comment https://forums.phpfreaks.com/topic/137387-need-to-print-out-dates-in-a-month-example-shown/#findComment-717858 Share on other sites More sharing options...
flyhoney Posted December 17, 2008 Share Posted December 17, 2008 You could take a look at this tutorial: http://discomoose.org/2005/10/19/generate-a-month-calendar-in-php/ And modify it to be linear. Link to comment https://forums.phpfreaks.com/topic/137387-need-to-print-out-dates-in-a-month-example-shown/#findComment-717864 Share on other sites More sharing options...
Solarpitch Posted December 17, 2008 Author Share Posted December 17, 2008 Thanks lads, I might try phpian's solution where I can use the checkdate function. The link you provided flyhoney will come in handy. Link to comment https://forums.phpfreaks.com/topic/137387-need-to-print-out-dates-in-a-month-example-shown/#findComment-717872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.