xubi Posted July 21, 2008 Share Posted July 21, 2008 i am using this code.... <td>Phone : </td><td><b><?php echo $Num; ?></td> and if $Num is Null, can i make this N/A...?? Or not Link to comment https://forums.phpfreaks.com/topic/115828-if-my-record-is-null-can-i-show-that-column-to-na/ Share on other sites More sharing options...
samshel Posted July 21, 2008 Share Posted July 21, 2008 sure you can... <td>Phone : </td><td><?php if($Num) echo $Num; else echo "N/A";?></td> Link to comment https://forums.phpfreaks.com/topic/115828-if-my-record-is-null-can-i-show-that-column-to-na/#findComment-595434 Share on other sites More sharing options...
jandrews3 Posted July 21, 2008 Share Posted July 21, 2008 Try using: if (is_numeric($Num)){echo $Num} else{print "N/A";} Link to comment https://forums.phpfreaks.com/topic/115828-if-my-record-is-null-can-i-show-that-column-to-na/#findComment-595435 Share on other sites More sharing options...
phpcodec Posted July 21, 2008 Share Posted July 21, 2008 or you could use this: <td>Phone : </td><td><?php echo ($Num?$Num:'N / A'); ?></td> Link to comment https://forums.phpfreaks.com/topic/115828-if-my-record-is-null-can-i-show-that-column-to-na/#findComment-595436 Share on other sites More sharing options...
DoddsAntS Posted July 21, 2008 Share Posted July 21, 2008 Hi, Just to add a bit of checking that would fill most situations Phone numbers may contain alternate characters so the is_numeric function will return false positives so I would use the following <td>Phone : </td><td><?php echo is_null($Num) ? 'N/A' : $Num;?></td> Link to comment https://forums.phpfreaks.com/topic/115828-if-my-record-is-null-can-i-show-that-column-to-na/#findComment-595446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.