I have a if NULL echo “Message” else $value.
There is some JavaScript hiding the input field, so they check it and enter the value.
If they don’t check it to enter the field, the db enters 0.00 and doesn’t specify NULL so my PHP if statement works.
How do I either set the variable as NULL if its blank, or set NULL in the INSERT statement?
`myTableField` decimal(10,2) default NULL,
Not sure exactly what you’re after, but you can run the below if statement to check what value was entered, and set to null accordingly:
If the variable $fieldvalue is set to null (or un-set), it will be inserted as a NULL in your DB according to your field definitions. Make sure your insert statement references the value without ‘ or ” encapsulating figures however (not needed as its a decimal field).