Newbie MySQL/PHP question re output formatting

2005-09-13 Thread Bill Whitacre

I can get this to work just fine:







Comes out $23,999.39

I'd like use the number_format() thingie on an array returned from a  
mysql_query.


My current program snippet looks like:


$res = mysql_query("SELECT org, COUNT(*), SUM(annual_cost) AS  
cost FROM a05

GROUP BY org ORDER BY cost DESC",$dbh);

if (!$res) {
  echo mysql_errno().": ". mysql_error ()."";
  return 0;
}

print "";

while ($thearray = mysql_fetch_array($res)) {

printf(" {$thearray[org]} 
 {$thearray["COUNT(*)"]} 
 $ {$thearray[cost]} ");

}

print "";



and works fine -- see <http://ibbmonitor.com/sked_1.php>, 3rd block  
of stuff down.


If I replace

{$thearray[cost]}

with

number_format({$thearray[cost]}, 2)

I get

$ number_format(7842554.24, 2)

in the cell where I would expect to get

$ 7,842,554.24

Any idea what I'm doing wrong?

Clearly, I don't understand arrays very well.

Thanks VERY much for any help on this.

bw

---
Bill Whitacre
[EMAIL PROTECTED]


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



tab-delimited text file import

2003-02-01 Thread Bill Whitacre
Does anyone have any hints on how to or where to look to find out how 
to import a number of tab-delimited text files with some header info 
that reside on a ftp server into a MySQL database using PHP?

How about doing this on a daily basis, automagically?

Thanks.

bw

---
Bill Whitacre
[EMAIL PROTECTED]


-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php