lebedev9114 Posted October 19, 2009 Share Posted October 19, 2009 Hi guys , i need some help. I have this loop : while ($row = mysql_fetch_assoc($Result)) { ?> <th><?php echo "<a href=http://".$row['booking_site'].">"; echo $row['bookingname']; echo "</a>"; ?> </th> <th><?php echo number_format($row['com'],0,'.',','); ?></th> <th><?php echo number_format($row['AlexaRanking'],0,'.',','); ?></th> 'com' - is an integeir i need help with replacing this $row['com'] IF the number is 0 with a DASH (-) how may i include an if an else statement or a prematch inside or outside the while loop? Link to comment https://forums.phpfreaks.com/topic/178204-solved-using-a-loop-help/ Share on other sites More sharing options...
anupamsaha Posted October 19, 2009 Share Posted October 19, 2009 Change: <th><?php echo number_format($row['com'],0,'.',','); ?></th> To: <th><?php echo ($row['com'] == 0) ? '-' : number_format($row['com'],0,'.',','); ?></th> Does this help? Link to comment https://forums.phpfreaks.com/topic/178204-solved-using-a-loop-help/#findComment-939561 Share on other sites More sharing options...
JAY6390 Posted October 19, 2009 Share Posted October 19, 2009 <th><?php echo ((int) $row['com'] == 0) ? '-' : number_format($row['com'],0,'.',','); ?></th> will do it, and will make sure that the value it's checking against is an integer value, so X will be 0, and will be replaced with - Link to comment https://forums.phpfreaks.com/topic/178204-solved-using-a-loop-help/#findComment-939562 Share on other sites More sharing options...
lebedev9114 Posted October 19, 2009 Author Share Posted October 19, 2009 Thank you very much guys ! Link to comment https://forums.phpfreaks.com/topic/178204-solved-using-a-loop-help/#findComment-939570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.