Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- for ($i = 0; $i < 7; $i++)
- {
- $sectionName = '';
- $sectionCutoffMax = 0;
- $sectionCutoffMin = 0;
- switch ($i)
- {
- case 0:
- $sectionName = 'I dag';
- $sectionCutoffMax = time();
- $sectionCutoffMin = time() - 86400;
- break;
- case 1:
- $sectionName = 'I går';
- $sectionCutoffMax = time() - 86400;
- $sectionCutoffMin = time() - 172800;
- break;
- case 2:
- $sectionName = 'Denne uge';
- $sectionCutoffMax = time() - 172800;
- $sectionCutoffMin = time() - 604800;
- break;
- case 3:
- $sectionName = 'Sidste uge';
- $sectionCutoffMax = time() - 604800;
- $sectionCutoffMin = time() - 1209600;
- break;
- case 4:
- $sectionName = 'Denne måned';
- $sectionCutoffMax = time() - 1209600;
- $sectionCutoffMin = time() - 2592000;
- break;
- case 5:
- $sectionName = 'Sidste måned';
- $sectionCutoffMax = time() - 2592000;
- $sectionCutoffMin = time() - (60 * 60 * 24 * 365);
- break;
- }
- $q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax . " ORDER BY published DESC LIMIT 50";
- $getArticles = mysql_query($q);
- if (mysql_num_rows($getArticles) > 0)
- {
- echo '<h2>' . $sectionName . '</h2>
- <ul>';
- while ($a = mysql_fetch_assoc($getArticles))
- {
- ?>
- <li><?php if($news_id !== $a['id']){ echo"<a href=\"".$path."/news/".$a['id']."\">"; } ?>
- <?php echo $a['title']; ?> »</a>
- <?php if($news_id !== $a['id']){ echo"</a>"; } ?></li>
- <?php }
- echo '</ul>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement