Link to home
Start Free TrialLog in
Avatar of rcowen00
rcowen00Flag for United States of America

asked on

PHP Array Null Values

The attached code does not work.  What I am attempting to do is to only update records that do not have a null value but the code is updating the field to "0000-00-00" vs leaving it null.   Any suggestions?  Thank you.
$i = 0;
        foreach ( $dateAssignedArray as $editID => $da) {
          $dtAssigned=rtrim($da);
          if (!empty($dtAssigned)){$update="UPDATE audit SET dateAssigned='$da' WHERE auditID=$editID";

        $updateRow=mysql_query($update)or die(mysql_error());
        $i++;}
          ELSE {
        }
       }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcowen00

ASKER

After running your suggestion, it didn't work but I realized because the field already had "0000-00-00" and I was deleting it, but that wasn't being looked at because it was null.  I realized that in most cases that will work when the current value is null but what if the user has a value in the field but wants to remove it, this will never work.  I believe then I want to check for isset.
Data in the field would do it.  Thus the value of var_dump().  Glad you got it solved and thanks for the points.