Jump to content

***RESOLVED*** efficient looping structure


mrplatts

Recommended Posts

I'm using a simple calendar display with using
[code]
<?php
for($m=8; $m<=12; $m++) {
$date_month = $m;
$date_year = 2006;

$theday = date(w, mktime(0, 0, 0, $date_month, 1, $date_year));
$daysinmonth = date("t", mktime(0, 0, 0, $date_month, 1, $date_year));
echo "<table align=center border=0>";
echo "<tr>><td colspan=7 align=center>".date("F", mktime(0, 0, 0, $date_month, 1, $date_year))." (".date("Y", mktime(0, 0, 0, $date_month, 1, $date_year)).")</td></tr>";
echo "<tr>";
echo "<td>Sun</td>";
echo "<td>Mon</td>";
echo "<td>Tue</td>";
echo "<td>Wed</td>";
echo "<td>Thu</td>";
echo "<td>Fri</td>";
echo "<td>Sat</td>";
echo "</tr>";
echo "<tr>";
for ($i=0;$i<$theday;$i++)
{
  echo "<td>&nbsp;</td>";
}
for ($list_day=1;$list_day<=$daysinmonth;$list_day++)
{
?>
[/code]
... well you get the idea.
I want to start showing the date at a specified start month and end display with a specified end month, in the next year. 

Is there a way to loop this efficiently?  I know I could do it with a convoluted set of loops.

More specifially, for example it would display from august 2006 -- June 2007.

Link to comment
https://forums.phpfreaks.com/topic/27792-resolved-efficient-looping-structure/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.