Jump to content

IF statement within an IF statement?


Recommended Posts

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

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.