How do I format this to output GB pounds

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

How do I format this to output GB pounds

Post by mhouldridge »

Hi,

I would like to output the following code to show the total value of all assets within my database in GB pounds.

Code: Select all

$sql = "SELECT SUM(value) AS tot FROM dedicated";
$result = mysql_query($sql) or die(mysql_error()); 
$line = mysql_fetch_array($result, MYSQL_ASSOC); 
setlocale(LC_MONETARY, 'en_GB');
echo money_format('0','$line['tot']')."\n";

This is erroring, as I have tried to format the code. I know that the following is wrong, but I dont know what to do;

Code: Select all

echo money_format('0','$line['tot']')."\n";
Please help.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

echo money_format('0',$line['tot'])."\n";
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

hi,

Thanks for that.. I get the error "Fatal error: Call to undefined function: money_format() in "

I do not think I have specified the following correctly;

Code: Select all

echo money_format([b]'0'[/b],$line['tot'])."\n";
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

Ok -

Do you know why I get this error ?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what OS you on?
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

windows
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

so, did my previous post not make you realise why it isn't working :roll:
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

ok... urghh

How would it read though?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

mhouldridge wrote:ok... urghh

How would it read though?
eh?
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

Its sorted now.

I have formatted it using;

number_format method.

thanks for your help, this forum rox!
Post Reply