rendered paste body<?php //connect to database elekchron include('db_elekchron.php'); $year = 0; $month = 0; $q_year = mysql_query('SELECT * FROM news ORDER BY dateAdded DESC'); while ($news_year = mysql_fetch_array($q_year)) { // define all the time variables $dateAdded = date('F j, Y g:i a T', $news_year['dateAdded']); $lastModified = date('F j, Y g:i a T', $news_year['lastModified']); $day = date('d', $news_year['dateAdded']); // Day of the month, 2 digits with leading zeros $nzday = date('j', $news_year['dateAdded']); // Day of the month without leading zeros // find # of comments for each post $newsID = $news_year['id']; $comments_query = "SELECT newsID FROM comments WHERE newsID = '" . $newsID . "'"; $commentsTotal = mysql_num_rows(mysql_query($comments_query)); $final_news = apply_emoticons($news_year['news']); print('<div class="post">'); if (isset($year) && $year < date('Y', $news_year['dateAdded'])) { $q_month = mysql_query('SELECT * FROM news WHERE dateAdded BETWEEN ' . $month . ' AND ' . mktime(0, 0, 0, 12, 0, $year) . ' ORDER BY dateAdded DESC'); $year = date('Y', $news_year['dateAdded']); while ($news_month = mysql_fetch_array($q_month)) { if (isset($month) && $month < date('n', $news_month['dateAdded'])) { print('<h1>' . date('F', $news_month['dateAdded']) . ' of ' . $year . '</h1>' . "\n"); ?> <dl class="archive"> <dt><a href="<?php print('archives.php?year=' . $year . '?month=' . $month . '?day=' . $day . '?title=' . $archives['title']); ?>"><?php print($nzday); ?> th</a></dt> <dd><a href="<?php print('archives.php?year=' . $year . '?month=' . $month . '?day=' . $day . '?title=' . $archives['title']); ?>"><?php print($archives['title']); ?></a></dd> <dd><?php print($commentsTotal . ' comments'); ?></dd> </dl> <?php } else { continue; } } } else { continue; } print('</div>'); }?>