Format price/currency from MYSQL database using PHP

Posted on 2007-10-11
Last Modified: 2010-08-05
I have a row for PRICE in my database and it is formatted as an integer with no commas.  I am trying to figure out how to print the price in PHP with appropriate commas (ex 9,000 or 15,000).  Does anyone have any ideas?  Thanks!
Question by:jeveloff2
    LVL 20

    Accepted Solution

    LVL 17

    Assisted Solution

    $number = 12345.67;  //number from DB
    $formatedNumber = number_format($number, 2);

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to dynamically set the form action using jQuery.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now