Jump to content

Archived

This topic is now archived and is closed to further replies.

aaronlzw_21

data retrieve from mysql is not in double

Recommended Posts

hi i have a small prob here. mysql table's column is in decimal with two decimal places. to store prices. i used a for loop to display the results in a form of a html table. but the results shown are always without the decimal places. did i do something wrong? here are my codes,

$queryResult = mysql_query($query)
$results = mysql_num_rows($queryResult)

for ($i=0; $i<$results; i++){
$row = mysql_fetch_array($queryResult);

echo "<td>". $row['monthlyCost']. "</td>";


}


its not the complete code but its something like that. thanks!

Share this post


Link to post
Share on other sites
You have to use number_format() to display any kind of precision, unless MySQL provides a number formatting function.

Share this post


Link to post
Share on other sites
[!--quoteo(post=372274:date=May 8 2006, 10:35 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 8 2006, 10:35 PM) [snapback]372274[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You have to use number_format() to display any kind of precision, unless MySQL provides a number formatting function.
[/quote]


erm i dun get wat u mean..

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.