Jump to content


Photo

data retrieve from mysql is not in double


  • Please log in to reply
2 replies to this topic

#1 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 08 May 2006 - 06:45 AM

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!

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 08 May 2006 - 02:35 PM

You have to use number_format() to display any kind of precision, unless MySQL provides a number formatting function.

Info: PHP Manual


#3 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 09 May 2006 - 01:05 AM

[!--quoteo(post=372274:date=May 8 2006, 10:35 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 8 2006, 10:35 PM) View Post[/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..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users