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

2005

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 “

  • . $monthyear ($count post$plural)
  • \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”; }

    Leave a Reply