Boofo
08-31-2002, 03:47 AM
Can anyone please tell me an easier way to do this? I want to have the thread views in a number format (with an apostrophe after 1000). Here is the code I got it to work with but there must be a better and easier way to accomplish this.
$dbview = $DB_site->query_first("SELECT SUM(views) AS totalviews FROM thread");
$allviews = $dbview[totalviews];
$countviews=$DB_site->query_first("SELECT SUM(views) AS views FROM thread WHERE postuserid='$userinfo[userid]'");
$userthreadviews=$countviews['views'];
$threadviewpercent = round(($userthreadviews / $allviews) * 100,2);
$userthreadviews=number_format($countviews['views']);
if ($userthreadviews AND $threadviewpercent <> "0") {
eval("\$threadviews = \"".gettemplate("getinfo_threadviews")."\";");
} else {
$threadviews = '';
}
This is the line I had to insert to get it to work right.
$userthreadviews=number_format($countviews['views']);
I tried doing the number_format in the first instance of this code, but it messed up the percentage of totalviews there.
$dbview = $DB_site->query_first("SELECT SUM(views) AS totalviews FROM thread");
$allviews = $dbview[totalviews];
$countviews=$DB_site->query_first("SELECT SUM(views) AS views FROM thread WHERE postuserid='$userinfo[userid]'");
$userthreadviews=$countviews['views'];
$threadviewpercent = round(($userthreadviews / $allviews) * 100,2);
$userthreadviews=number_format($countviews['views']);
if ($userthreadviews AND $threadviewpercent <> "0") {
eval("\$threadviews = \"".gettemplate("getinfo_threadviews")."\";");
} else {
$threadviews = '';
}
This is the line I had to insert to get it to work right.
$userthreadviews=number_format($countviews['views']);
I tried doing the number_format in the first instance of this code, but it messed up the percentage of totalviews there.