mysql | SELECT COUNT? adding decimal places. code inside!

Discussion in 'PHP' started by cornetofreak, May 9, 2008.

  1. #1
    heres my code

    <?php
    $result = mysql_query('select count(*) from v2links where `checked` = 1');
    if (!$result) {
        die('Could not query:' . mysql_error());
    }
    echo mysql_result($result, 0);
    
    ?>
    Code (markup):
    but it apears as "15968"

    how do i make it show "15,968" or "15.968"?? "," is better
    please help
     
    cornetofreak, May 9, 2008 IP
  2. TeraTask

    TeraTask Peon

    Messages:
    37
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    May want to take a look at the number_format() function.
     
    TeraTask, May 9, 2008 IP
  3. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    how would i place the number format i keep getting errors?
     
    cornetofreak, May 9, 2008 IP
  4. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Yee'hee!

    echo number_format(mysql_result($result, 0), 0, '.', ',');
    PHP:
     
    chopsticks, May 9, 2008 IP
  5. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    its done now thanks i was going wrong by..
    
    echo (number_format = mysql_result($result, 0), 0, '.', ','));
    PHP:
    thanks again
     
    cornetofreak, May 9, 2008 IP
  6. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Your welcome! :)
     
    chopsticks, May 9, 2008 IP