SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Nov 2002
    Location
    Maryland
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/MySQL Beginner Needs Help

    When I add a number to my MySQL database with a comma say for example 34,000, I get only 34 when it is outputted into my web document. How do I get around this problem? I want to be able to add a number with a comma and then it to be outputted with a comma.

    Any help is greatly appreciated.

    Jeff

  2. #2
    SitePoint Enthusiast mind21_98's Avatar
    Join Date
    Apr 2003
    Location
    Inside, away from the light.
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JeffGSR
    When I add a number to my MySQL database with a comma say for example 34,000, I get only 34 when it is outputted into my web document. How do I get around this problem? I want to be able to add a number with a comma and then it to be outputted with a comma.

    Any help is greatly appreciated.

    Jeff
    You'll need to get rid of the comma first using PHP:

    PHP Code:
    $number preg_replace("/,/g"""$number); 
    then you can insert it into the DB. I'm not sure how you'd go about putting the comma back in though.

  3. #3
    SitePoint Enthusiast Powerlord's Avatar
    Join Date
    May 2003
    Location
    Mason, MI, USA
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can get the comma back when extracting from the DB by using the number_format() function.
    Ross Bemrose,
    Independant MySQL/Perl/PHP Developer


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •