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
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu May 26, 2005 4:58 am
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.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 26, 2005 4:59 am
Code: Select all
echo money_format('0',$line['tot'])."\n";
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu May 26, 2005 5:11 am
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";
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 26, 2005 5:28 am
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.
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu May 26, 2005 6:14 am
Ok -
Do you know why I get this error ?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 26, 2005 6:16 am
what OS you on?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 26, 2005 6:56 am
so, did my previous post not make you realise why it isn't working
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu May 26, 2005 7:25 am
ok... urghh
How would it read though?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 26, 2005 8:06 am
mhouldridge wrote: ok... urghh
How would it read though?
eh?
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu May 26, 2005 8:11 am
Its sorted now.
I have formatted it using;
number_format method.
thanks for your help, this forum rox!