PHP/MySQL: Setting a field to NULL if a form field is left blank
For those of you working with PHP and MySQL who want to set a field in MySQL to NULL if the corresponding field in an HTML form is left blank, here is a slick trick:
UPDATE table_name SET date_field=IF('$date_value'='',NULL,'$date_value')
For text fields this isn't a huge deal, but for any of the formatted field types like "date" or "decimal," setting them equal to an empty string (i.e. '') results in them having values like 0000-00-00 and 0.00. So this little "if" shorthand in MySQL is a great solution.
UPDATE table_name SET date_field=IF('$date_value'='',NULL,'$date_value')
For text fields this isn't a huge deal, but for any of the formatted field types like "date" or "decimal," setting them equal to an empty string (i.e. '') results in them having values like 0000-00-00 and 0.00. So this little "if" shorthand in MySQL is a great solution.

WHERE ID = '$id'
(for example) at the end of your SQL query, the whole column is updated to null even if there are column entries that are NOT Null.