You're probably not fetching it correctly from the database, post the code you're using to fetch it from the database and your current schema and data from your news tables.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="shortcut icon" href="{url}/app/tpl/skins/{skin}/images/favicon.ico" type="image/vnd.microsoft.icon"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>{hotelName} - News Articles</title>
<link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/common.css?<?= time(); ?>" type="text/css">
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs2.js"></script>
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/visual.js"></script>
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs.js"></script>
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/common.js"></script>
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/fullcontent.js"></script>
<script type="text/javascript">
document.habboLoggedIn = true;
var habboName = "{username}";
var habboId = {userid};
var habboReqPath = "";
var habboStaticFilePath = "{url}/app/tpl/skins/Habbo";
var habboImagerUrl = "http://www.habbo.com/habbo-imaging/";
var habboPartner = "";
var habboDefaultClientPopupUrl = "{url}/client";
window.name = "habboMain";
if (typeof HabboClient != "undefined") {
HabboClient.windowName = "eac955c8dbc88172421193892a3e98fc7402021a";
HabboClient.maximizeWindow = true;
}
</script>
<!--[if IE 8]>
<link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie8.css" type="text/css">
<![endif]-->
<!--[if lt IE 8]>
<link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie.css" type="text/css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie6.css" type="text/css" />
<script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/pngfix.js"></script>
<script type="text/javascript">
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
</script>
<style type="text/css">
body { behavior: url({url}/app/tpl/skins/Habbo/js/csshover.htc); }
</style>
<![endif]-->
</head>
<body id="news">
<div id="overlay"></div>
<?php include ("includes/header.php"); ?>
<ul id="navi">
<li class="metab"><a href="{url}/me">{username}</a><span></span></li>
<li class="selected"><strong>Community</strong><span></span></li>
<li id="tab-register-now"><a href="{url}/store">Store</a><span></span></li>
<?php
if(isset($_SESSION['user']['id']))
if(mysql_result(mysql_query("SELECT rank FROM users WHERE id = '" . $_SESSION['user']['id'] . "'"), 0) >= 3) {
echo '<li id="tab-register-now"><a href="{url}/allseeingeye/index.php" target="_blank">Staff Panel</a><span></span></li>';
}
?>
</ul>
<div id="habbos-online"><div id="content"><div class="cbb "><span><b>{online}</b><br>users<br>online</span></div></div></div>
</div>
</div>
<div id="content-container">
<div id="navi2-container" class="pngbg">
<div id="navi2" class="pngbg clearfix">
<ul>
<li class=""><a href="{url}/community">Community</a></li>
<li class="selected">News</li>
<li class=""><a href="{url}/staff">{hotelname} Staff</a></li>
<li class=""><a href="{url}/topstats">Top Player Stats</a></li>
<li class=""><a href="{url}/trusteddealers">Trusted Dealers</a></li>
<li class=""><a href="{url}/stats">{hotelname} Statistics</a></li>
</ul>
</div>
</div>
<div id="container">
<div id="content" style="position: relative" class="clearfix">
<div id="column1" class="column">
<div class="habblet-container ">
<div class="cbb clearfix red ">
<h2 class="title">News Articles</h2>
<div id="article-archive">
<ul>
<?php
{
for ($i = 0; $i < 6; $i++)
{
$sectionName = "";
$sectionCutoffMax = 0;
$sectionCutoffMin = 0;
switch ($i)
{
case 0:
$sectionName = 'Today';
$sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;
break;
case 1:
$sectionName = 'Yesterday';
$sectionCutoffMax = time() - 86400;
$sectionCutoffMin = time() - 172800;
break;
case 2:
$sectionName = 'This week';
$sectionCutoffMax = time() - 172800;
$sectionCutoffMin = time() - 604800;
break;
case 3:
$sectionName = 'Last week';
$sectionCutoffMax = time() - 604800;
$sectionCutoffMin = time() - 1209600;
break;
case 4:
$sectionName = 'This month';
$sectionCutoffMax = time() - 1209600;
$sectionCutoffMin = time() - 2592000;
break;
case 5:
$sectionName = 'Last month';
$sectionCutoffMax = time() - 2592000;
$sectionCutoffMin = time() - 5184000;
break;
}
$q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax . " ORDER BY published DESC";
$getArticles = mysql_query($q);
if (mysql_num_rows($getArticles) > 0)
{
echo '<br>';
echo '<h2>' . $sectionName . '</h2>';
while ($a = mysql_fetch_assoc($getArticles))
{
if($a['id'] == $_GET['id'])
{
echo '' . $a['title'] . ' »';
}
else
{
echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . ' »</a></li>';
}
}
}
}
}
?>
</ul>
</div>
</div>
</div>
<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
</div>
<div id="column2" class="column">
<div class="habblet-container ">
<div class="cbb clearfix notitle ">
<div id="article-wrapper">
<h2>{newsTitle} - By: {newsAuthor}</h2>
<div class="article-meta">Posted {newsDate}
</div>
<div class="article-body">
{newsContent}
<br><br>
<script type="text/javascript" language="Javascript">
document.observe("dom:loaded", function() {
$$('.article-images a').each(function(a) {
Event.observe(a, 'click', function(e) {
Event.stop(e);
Overlay.lightbox(a.href, "Image is loading");
});
});
$$('a.article-2729').each(function(a) {
a.replace(a.innerHTML);
});
});
</script>
</div>
</div>
</div>
</div>
</div> </div> </div> </div>
<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
</div>
</div>
<script type="text/javascript">
document.observe('dom:loaded', function() {
CurrentRoomEvents.init();
});
</script>
</div>
<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
<script type="text/javascript">
HabboView.run();
</script>
<!--[if lt IE 7]>
<script type="text/javascript">
Pngfix.doPngImageFix();
</script>
<![endif]-->
<?php include('includes/footer.php'); ?>
<?php include('includes/checktheban.php'); ?>
</body>
</html>
if (mysql_num_rows($getArticles) > 0)
{
echo '<br>';
echo '<h2>' . $sectionName . '</h2>';
while ($a = mysql_fetch_assoc($getArticles))
{
if($a['id'] == $_GET['id'])
{
echo '' . $a['title'] . ' »';
}
else
{
echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . ' »</a></li>';
}
}
}
too long to posted, i've put it hereMy guess is that its something to do with this part, maybe your schema isn't matching up - Post your cms_news schema and data
Code:$q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax . " ORDER BY published DESC"; $getArticles = mysql_query($q); if (mysql_num_rows($getArticles) > 0) { echo '<br>'; echo '<h2>' . $sectionName . '</h2>'; while ($a = mysql_fetch_assoc($getArticles)) { if($a['id'] == $_GET['id']) { echo '' . $a['title'] . ' »'; } else { echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . ' »</a></li>'; } } }
SELECT * FROM cms_news WHERE published >= 1601386430 AND published <= 1601300030 ORDER BY published DESC
SELECT MIN(published) FROM `cms_news`;
SELECT MAX(published) FROM `cms_news`;
yep i get 1595509353Your code seems fine to me, its your timestamps that are the issue. If you select the maximum published date (most recent article), you'll get 1595509353 (unix) which if you convert to a DateTime is 07/23/2020 @ 1:02pm (UTC)
Run this and confirm you get 1595509353:
Code:SELECT MAX(published) FROM `cms_news`;
Great, so we're on the same page. What this query returns is, the published date (in unix timestamp form) for the most recent article you have created in your database. Try creating an article now and seeing if it shows up, if it doesn't then share the `published` column value for the new article with me and I can take a look, chances are if that happens is that you aren't setting the correct timestamp upon creation.yep i get 1595509353
no it doesn't show when i create a new one eitherGreat, so we're on the same page. What this query returns is, the published date (in unix timestamp form) for the most recent article you have created in your database. Try creating an article now and seeing if it shows up, if it doesn't then share the `published` column value for the new article with me and I can take a look, chances are if that happens is that you aren't setting the correct timestamp upon creation.
DROP TABLE IF EXISTS `cms_news`;
CREATE TABLE `cms_news` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`image` varchar(100) NOT NULL DEFAULT '0',
`shortstory` text NOT NULL,
`longstory` text NOT NULL,
`date` int(11) NOT NULL DEFAULT '0',
`type` varchar(100) NOT NULL DEFAULT '1',
`roomid` varchar(100) NOT NULL DEFAULT '1',
`updated` enum('0','1') NOT NULL DEFAULT '0',
`published` int(10) DEFAULT '0',
`author` varchar(255) NOT NULL DEFAULT 'Bran',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1;
SELECT published FROM cms_news ORDER BY id DESC LIMIT 1;
1601383989It should be a number if that helps, just open your table and look for the "published" column, and paste the value.
If you can't work out how to do that, run this query and it should give you the value:
Code:SELECT published FROM cms_news ORDER BY id DESC LIMIT 1;
SELECT * FROM cms_news WHERE published >= 1601300030 AND published <= 1601300030 ORDER BY published DESC
sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;
$sectionCutoffMax = 1601390219
$sectionCutoffMin = 1601303819
SELECT * FROM cms_news WHERE published >= 1601390219 AND published <= 1601303819 ORDER BY published DESC
that's my news.php lolFrom what I saw on your screen, you are checking the same timestamp, which will obviously return 0 rows.
A dump of your PHP string (the query you run):
Code:SELECT * FROM cms_news WHERE published >= 1601300030 AND published <= 1601300030 ORDER BY published DESC
I'm not sure what code you posted to me, but I don't think that's what your actual code looks like.
Code:sectionCutoffMax = time(); $sectionCutoffMin = time() - 86400;
Which from my time() becomes
Code:$sectionCutoffMax = 1601390219 $sectionCutoffMin = 1601303819
The query (it returns your news articles):
Code:SELECT * FROM cms_news WHERE published >= 1601390219 AND published <= 1601303819 ORDER BY published DESC
Everything above is based only on the first iteration, but from my perspective, it should work with the code you posted and the data in your tables.