php - Update INT/DECIMAL field with a null/no value -
i have lot of input box's. each input box linked int or decimal mysql field , displayed inside text box.
the default value of each int/decimal null when user first opens page, nothing shown inside text box's.
i have update query updates value of each input box respected mysql field.
my problem is, each input box doesn't typed in, value of field switches null 0.
i having trouble figuring out way update un-touched input's null , not have untouched values go 0. can help?
defining variables goes like:
if(nullblank($_post['variable1']) == false) $variable1 = $_post['variable1']; else $variable = ""; i've tried: $variable = null;
my update query looks this:
mysql_query("update `table` set `variable1`= '" . $variable1 . "' = my nullblank() function
function nullblank($data) { if(is_null($data)) $value = true; elseif(strlen($data) <= 0) $value = true; elseif($data === "") $value = true; else $value = false; return $value; }
set $variable1 "null" (the string). way end in query null, represents null in sql.
Comments
Post a Comment