Inserting comma to mysql decimal field...

  • tiffix
  • Student
  • Student
  • User avatar
  • Posts: 65
  • Loc: kenya

Post 3+ Months Ago

i store my amounts to a mysql decimal field called "amount(10,2)". now when i read the amount back to php from mysql i get 1000.00 yet i want to read them as 1,000.00. is it a possibility? kindly let me know
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

You will not actually be "inserting a comma" into a decimal field. :)

What you will be doing, is using PHP to format the value you get from MySQL. Using the number_format() function.
  • tiffix
  • Student
  • Student
  • User avatar
  • Posts: 65
  • Loc: kenya

Post 3+ Months Ago

It was so Easy... Thanks so Much Joebert for the link...

Code: [ Select ]
$number=1000.00;
    echo number_format($number);
    
    //output
    //1,000.00
  1. $number=1000.00;
  2.     echo number_format($number);
  3.     
  4.     //output
  5.     //1,000.00

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 85 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.