Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question How convert "0" to "n/a"?

    I use php to dynamically display numeric data from a mysql database in a table. See it here: http://www.pokerprovince.com/player.php

    I would like to make it display "n/a" in place of "0". Essentially I want to convert the number zero to the text n/a.

    The code for the table column display is:

    <?php echo $row_pokercounts['count_tables']; ?>
    Is it possible to add some code to this to do the conversion? Maybe something that says: if count_tables equals 0 then display n/a?

    Thanks in advance for any help.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Welcome to CodingForums, clubwager!

    You just need something like this:

    Code:
    <?php
    
    if  ($row_pokercounts['count_tables'] == 0) {
       echo "n/a";
    } else {
       echo $row_pokercounts['count_tables'];
    }
    
    ?>
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Smile

    That worked perfectly without any changes. Thank you so much!


  •  

    Posting Permissions

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