liamloveslearning Posted May 24, 2010 Share Posted May 24, 2010 Hi everyone, Im a bit dumbfounded here, Is it possible to have an IF statement WITHIN an IF statement? I have a variable being called if the table isnt null, I then need another statement to show if date is older than 14 days, does this make sense? At the moment I have <?php if (@$row_rsworksorders1['intraartapproval'] != "") { ?> <?php echo KT_FormatForList(date('d/m/Y',strtotime($row_rsworksorders1['intraartapproval'])), 20); ?> <?php } else { ?> <?php } ?> I need this line... <?php echo KT_FormatForList(date('d/m/Y',strtotime($row_rsworksorders1['intraartapproval'])), 20); ?> to show <span style="color:#ff0000;"><?php echo KT_FormatForList(date('d/m/Y',strtotime($row_rsworksorders1['intraartapproval'])), 20); ?></span> If the date is older than 14 days... Link to comment https://forums.phpfreaks.com/topic/202739-if-statement-within-an-if-statement/ Share on other sites More sharing options...
marcus Posted May 24, 2010 Share Posted May 24, 2010 <?php if($blah == 'cake'){ if($cake == 'blah'){ // do this } } ?> Link to comment https://forums.phpfreaks.com/topic/202739-if-statement-within-an-if-statement/#findComment-1062594 Share on other sites More sharing options...
-Karl- Posted May 24, 2010 Share Posted May 24, 2010 Also, why do you keep closing PHP tags, to open it again? <?php if (@$row_rsworksorders1['intraartapproval'] != "") { echo KT_FormatForList(date('d/m/Y',strtotime($row_rsworksorders1['intraartapproval'])), 20); } else { //else statement here } ?> Link to comment https://forums.phpfreaks.com/topic/202739-if-statement-within-an-if-statement/#findComment-1062596 Share on other sites More sharing options...
Alex Posted May 24, 2010 Share Posted May 24, 2010 Of course, you can nest as many if statements as necessary. echo ($t = strtotime($row_rsworksorders1['intraartapproval'])) < time() - 60*60*24*14 ? '<span style="color:#ff0000;">' . KT_FormatForList(date('d/m/Y',$t), 20) . '</span>' : KT_FormatForList(date('d/m/Y',$t), 20); Link to comment https://forums.phpfreaks.com/topic/202739-if-statement-within-an-if-statement/#findComment-1062598 Share on other sites More sharing options...
liamloveslearning Posted May 24, 2010 Author Share Posted May 24, 2010 Brilliant, thanks everyone, and im unsure Karl it is a pain its just how ive always done it for some strange reason Link to comment https://forums.phpfreaks.com/topic/202739-if-statement-within-an-if-statement/#findComment-1062600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.