source view: blog-archive.php


<?php



  require 'db.connect.php';
  require './classes/Page.php';
  $page = new Page();
  $page->setTitle( 'blog archive' );
  $page->setParentURL( 'current.php' );



  $page->addHeader( <<<EOCSS
    <style type="text/css">
      ul
      {
        list-style:    none;
        margin-bottom: 2em;
        margin-top:    0em;
      }

      ul li
      {
        margin-left: -2.5em;
      }
    </style>
EOCSS
);



  $page->printPageHeader();



  $blog_history_query_string = <<<EOQ
SELECT
  DATE_FORMAT( bp.postDateTime, '%M %Y' ),
  DATE_FORMAT( bp.postDateTime, '%M %D' ),
  bp.postURL,
  bp.blogPostTitle,
  (
    SELECT COUNT(*)
    FROM tblBlogPostComments
    WHERE blogPostID = bp.blogPostID
  )
FROM tblBlogPosts bp
WHERE bp.isVisible = 1
ORDER BY bp.postDateTime DESC
EOQ;
  $blog_history_query = $mysql->prepare( $blog_history_query_string );
  $blog_history_query->execute();
  $blog_history_query->bind_result( $post_month, $post_date, $post_url, $post_title, $comment_count );

  $last_month_header = '';
  while ( $blog_history_query->fetch() )
  {
    if ( $last_month_header != $post_month )
    {
      if ( strlen( $last_month_header ) )
      {
?>
          </ul>
<?php
      }

      $last_month_header = $post_month;
?>
          <h3><?php print strtolower( $last_month_header ); ?></h3>
          <ul>
<?php
        
    }
?>
            <li><?php print $post_date; ?>: <a href="/current/<?php print $post_url; ?>" target="_top"><?php print $post_title;?></a></li>
<?php
  }

  $blog_history_query->close();
?>
          </ul>
<?php



  $page->printPageFooter();
  
  
  
?>