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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -