Hello,
I have a page for inserting data into an sql database with an html form. It looks a bit like this:
$SQL = " INSERT INTO listings ";
$SQL = $SQL . " (paid, business_category, businesscategory, business_name,....
$SQL = $SQL . " ('$paid','$business_category','$businesscategory','$business_name',...
Then I define the values in the form and send the values to the database when it is submitted.
Works fine except that some fields are set in the database to default to NULL and when I use this form to add data to the database they lose their NULL status, even if I don't enter any data in the input field of the form. I want them to stay NULL if I don't enter any data. I realise I can use UPDATE `business_category` SET `grading2` = NULL ... but there's no simple way to do this from a form only when the input field is blank. Is there another way to do it?
Thanks
I have a page for inserting data into an sql database with an html form. It looks a bit like this:
$SQL = " INSERT INTO listings ";
$SQL = $SQL . " (paid, business_category, businesscategory, business_name,....
$SQL = $SQL . " ('$paid','$business_category','$businesscategory','$business_name',...
Then I define the values in the form and send the values to the database when it is submitted.
Works fine except that some fields are set in the database to default to NULL and when I use this form to add data to the database they lose their NULL status, even if I don't enter any data in the input field of the form. I want them to stay NULL if I don't enter any data. I realise I can use UPDATE `business_category` SET `grading2` = NULL ... but there's no simple way to do this from a form only when the input field is blank. Is there another way to do it?
Thanks