PDA

View Full Version : php number format


b6gm6n
08-05-2006, 08:13 AM
Why can't i use number_format twice? - plugins below work... first shows the right format "1,000" etc...

$query = "SELECT SUM(views), SUM(filesize), count(*) FROM photos";
$totalv = mysql_query($query);
list( $totalviews, $diskuse, $totalphotos ) = mysql_fetch_row($totalv);
mysql_free_result($totalv);

$query = "SELECT count(*) FROM comments";
$totalv = mysql_query($query);
list( $posttotal ) = mysql_fetch_row($totalv);
mysql_free_result($totalv);

// get users from vb

$utable = "user";

$query = "SELECT * FROM $utable";
$querytot = mysql_query($query);
$totalusers = mysql_num_rows($querytot);

$diskspace = $diskuse/1048576;
$diskspace = number_format( $diskspace, 1 );
$diskspace = "$diskspace MBytes";

$posttotal = number_format( $posttotal );
$totalphotos = number_format( $totalphotos );
$totalviews = number_format( $totalviews );
$diskuse = number_format( $diskuse );
$totalusers = number_format( $totalusers );

I needed another plugin to count another gallery install in the same database...but the numbers are not formatted... results show but this one shows "1000" <- no format...

$querycc = "SELECT SUM(views), SUM(filesize), count(*) FROM pp_photos";
$totalcc = mysql_query($querycc);
list( $totalviews2, $diskuse2, $totalphotos2 ) = mysql_fetch_row($totalcc);
mysql_free_result($totalcc);

$querycc = "SELECT count(*) FROM pp_comments";
$totalcc = mysql_query($querycc);
list( $posttotal2 ) = mysql_fetch_row($totalcc);
mysql_free_result($totalcc);

// get users from vb

$utable = "user";

$query = "SELECT * FROM $utable";
$querytot = mysql_query($query);
$totalusers = mysql_num_rows($querytot);

$diskspace2 = $diskuse2/1048576;
$diskspace2 = number_format( $diskspace2, 1 );
$diskspace2 = "$diskspace2 MBytes";

$posttotalcc = number_format( $posttotalcc );
$totalphotoscc = number_format( $totalphotoscc );
$totalviewscc = number_format( $totalviewscc );
$diskusecc = number_format( $diskusecc );
$totalusers = number_format( $totalusers );

why is that? please advise

-M