Log in

View Full Version : How do I add commas to these numbers?


Gutspiller
08-03-2002, 11:34 PM
I have this on my front page:


<?
$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 $threads[total];
?>


It grabs how many total threads I have in all those forums. I want the total number displayed though to have a comma intween every three digits so when it shows 11000 it shows 11,000.

Can somebody please help me with this little hackie thingie? I would really appreciate any help somebody can provide.

Thanks.

Xenon
08-03-2002, 11:47 PM
oh, intresting structur

wouldn't it be easier to use query_first instead of fetch_array($DB_site->query....) ?

i think this would be what ya want:
$last24 = time() - 0;
$threads = $DB_site->query_first("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]);

Gutspiller
08-05-2002, 08:36 PM
Thanks works good.