Page 1 of 1

How do I format this to output GB pounds

Posted: Thu May 26, 2005 4:58 am
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.

Posted: Thu May 26, 2005 4:59 am
by JayBird

Code: Select all

echo money_format('0',$line['tot'])."\n";

Posted: Thu May 26, 2005 5:11 am
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";

Posted: Thu May 26, 2005 5:28 am
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.

Posted: Thu May 26, 2005 6:14 am
by mhouldridge
Ok -

Do you know why I get this error ?

Posted: Thu May 26, 2005 6:16 am
by JayBird
what OS you on?

Posted: Thu May 26, 2005 6:54 am
by mhouldridge
windows

Posted: Thu May 26, 2005 6:56 am
by JayBird
so, did my previous post not make you realise why it isn't working :roll:

Posted: Thu May 26, 2005 7:25 am
by mhouldridge
ok... urghh

How would it read though?

Posted: Thu May 26, 2005 8:06 am
by JayBird
mhouldridge wrote:ok... urghh

How would it read though?
eh?

Posted: Thu May 26, 2005 8:11 am
by mhouldridge
Its sorted now.

I have formatted it using;

number_format method.

thanks for your help, this forum rox!