Hi Can this be done?? and if so how I want some text to show unless 0 shows. I dont mean a zero result from the data base. In context eg Brian has 4 (i want to show) Brian has 0 (i don't want to show) 4 and 0 comes from a data base. Really any number greater than 0 I want to show!! Hope someone can help - if this makes sense Regards
if ($number > 0){ print 'Brian has '.$number; } PHP: So you are only displaying (printing) the text if the number variable is greater than zero. -Ryan
You could also do the following if($number == 0){ echo "Brian doesn't have any apples"; } elseif($number == 1){ echo "Brian has one apple"; } else { echo "Brian has" . $number . "apples"; } PHP:
Or if ($number == 0) { echo "Brian doesn't have any apples"; } else { echo "Brian has ". $number ." apple". ($number != 1 ? 's' : '') .'.'; } PHP:
Alternatively, you might want to use the following: Forget it, there are already too many above... Just kidding. Bye
Wait, wait, or maybe this. switch($number) { case 0: echo "Brian doesn't have any apples"; break; case 1: echo "Brian has one apple"; break; default: echo "Brian has" . $number . "apples"; } Code (markup):