liamloveslearning Posted May 17, 2010 Share Posted May 17, 2010 Hi everyone, Im having trouble with a conditional statement, If my field date of id x isnt null i want it to show the date, if the date is left null i want it to show nothing. My code is as follows <?php if (@$row_testif['intraartapproval'] != "") { ?> <?php $today = $row_rsworksorders1['intraartapproval']; $est = strtotime('+15 day', strtotime($today)); print date('d/m/Y', $est); ?> <?php } else { ?> Else text <?php } ?> It seems to be looking at all the rows and only working if every single one of them is null as opposed to the 1 row containing the id Link to comment https://forums.phpfreaks.com/topic/202018-if-statement-trouble/ Share on other sites More sharing options...
liamloveslearning Posted May 17, 2010 Author Share Posted May 17, 2010 Ive now got it working only Its not calculating the date +15 days, so its showing empty for all rows, Can you have php statements within an else? <?php if (@$row_testif['intraartapproval'] == "") { ?> Empty <?php } else { ?> <?php $today = $row_rsworksorders1['intraartapproval']; $est = strtotime('+15 day', strtotime($today)); print date('d/m/Y', $est); ?> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/202018-if-statement-trouble/#findComment-1059385 Share on other sites More sharing options...
liamloveslearning Posted May 17, 2010 Author Share Posted May 17, 2010 Sorted! i was using the wrong variables. Link to comment https://forums.phpfreaks.com/topic/202018-if-statement-trouble/#findComment-1059388 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.