BLOG DESIGN SOLUTIONS If showbymonth is false, another (Frontpage web hosting)
BLOG DESIGN SOLUTIONS If showbymonth is false, another do-while loop is started. The desired output for the loop is a heading for the year, followed by a list of months in that year:
2004
- November 2004 (1 post)
- December 2004 (4 posts)
2005
- January 2005 (9 posts)
- February 2005 (12 posts)
So the headings are not repeated with every row, the normal loop is preceded by some logic that determines whether there has been a change of year; if so, the list is closed, and a new heading is written. $plural = ($count==1) ? “” : “s”; echo “
\n”; } while ($myposts = mysql_fetch_array($result)); echo “
“; } break; } ?>
After the year headings have been checked for, the month is written with a link back to the archive page so that the posts for that month can be viewed on a page. Note the shorthand logic used to determine whether the word post should be singular or plural, depending on the number of posts for that month. The following line: $plural = ($count==1) ? “” : “s”; could also have been written as follows: if ($count==1) { $plural = “”; } else { $plural = “s”; }