Log in

View Full Version : Help me finish these few lines of code


Gutspiller
01-04-2003, 08:51 PM
I have this code



<?
$last24 = time() - 86400;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost > $last24 AND (forumid = '143' OR forumid = '162' OR forumid = '161' OR forumid = '163' OR forumid = '145' OR forumid = '153' OR forumid = '164' OR forumid = '155' OR forumid = '167' OR forumid = '158' OR forumid = '165' OR forumid = '166')"));
echo $threads[total];
?>



which outputs the number of threads in a few of my forums. It's used to show how much news is posted every 24 hours. Those forum ids are the ids for all my forums for news. But the output number is not only the number of threads, but REPLIES also. Since I only want it to track news and news is only in the first post of each thread, can somebody help me get it so that it doesn't count replies?

I'm also using close to the same code


<?
$last24 = time() - 0;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost < $last24 AND (forumid = '143' OR forumid = '162' OR forumid = '161' OR forumid = '163' OR forumid = '145' OR forumid = '153' OR forumid = '164' OR forumid = '155' OR forumid = '167' OR forumid = '158' OR forumid = '165' OR forumid = '166' OR forumid = '127')"));
echo number_format($threads[total]);
?>

to track the total amount of news posts ever posted. On this one I don't know if it's tracking replies also or not, but if it is, I don't want it too.

Let me know if you need more info, if you care to see how I'm using it you can head to http://www.3dNewz.com and see it in the top right of the front page.

Thanks for any help you can provide.

Xenon
01-04-2003, 09:31 PM
hmm, it doesn't look wrong, seems everything is ok, but you should make it better readable:
also the lastpost < time() - 0 is not needed...

<?
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE forumid IN (143,162,161,163,145,153,164,155,167,158,165,166,1 27)"));
echo number_format($threads[total]);
?>


and yes, it's just counting the thread ammount, not the replies,

Gutspiller
01-04-2003, 10:10 PM
Originally posted by Xenon
hmm, it doesn't look wrong, seems everything is ok, but you should make it better readable:
also the lastpost < time() - 0 is not needed...

<?
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE forumid IN (143,162,161,163,145,153,164,155,167,158,165,166,1 27)"));
echo number_format($threads[total]);
?>


and yes, it's just counting the thread ammount, not the replies,

Well I wasn't sure about the bottom code that I posted, but the first code that I posted, I know for a fact is counting the replies, because on days that I don't post news it will say 1 or a few posts and then I look at people have made replies to news posts. So I still need help with the top code on how to fix it. Thanks so far though. :)

Xenon
01-04-2003, 10:17 PM
yes, the first one would update when a new post is made instead of this:
WHERE lastpost < $last24

useWHERE dateline < $last24