...

View Full Version : How convert "0" to "n/a"?



clubwager
08-28-2006, 03:00 AM
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.

vinyl-junkie
08-28-2006, 03:09 AM
Welcome to CodingForums, clubwager! :D

You just need something like this:


<?php

if ($row_pokercounts['count_tables'] == 0) {
echo "n/a";
} else {
echo $row_pokercounts['count_tables'];
}

?>

clubwager
08-28-2006, 05:14 AM
That worked perfectly without any changes. Thank you so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum