Bill Whitacre wrote:
        printf("<tr><td> {$thearray[org]} </td>
        <td align=right> {$thearray["COUNT(*)"]} </td>
        <td align=right> $ {$thearray[cost]} </td></tr>");
If I replace
{$thearray[cost]}
with
number_format({$thearray[cost]}, 2)

Although this is a MySQL mailing list and your problem is not MySQL related, but a PHP question I'll give you a brief answer.

PHP does not evaluate functions inside a double quoted string, so you should use:
"<tr><td> ".number_format($thearray['cost'],2)." </td><td align......."

Furthermore, using $thearray[cost] is not advisable; PHP will try to find a constant named 'cost' and if it can't find one it will use the string itself as the value. Use a real string (quoted) instead of relying on this feature:
$thearray['cost'] or $thearray["cost"]

Also you can use aliases in your query to avoid things like $thearray["COUNT(*)"];
Use something like this in your query:
SELECT .... COUNT(*) AS `count` .... FROM ....
and you can use $thearray['count'] instead

As a last pointer, printf() is pretty much useless here since you don't use any variable formatting features of printf() here. print() or echo() are more suitable in this case.

Regards, Jigal

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to