Jump to content

If statement trouble


Recommended Posts

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

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 } 

?>

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.