02-05-2009, 08:06 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Edit: D'oh, you beat me too it
First we move the decimal point one place to the left (by dividing it by 10), then sprintf formats the result.
%0.1F (or %.nF) == format the value given as a floating point number (F) to one decimal place (0.1, the number after the . is the number of places, so %.4F would be to 4 decimal places and so on).
An alternative way (and a lot less elegant)
PHP Code:
echo round($row['cargo_11'] / 10, 1);
sprintf is a very powerful and useful function.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|