I am working on a project where I am using database driven dropdown lists on which i also add Other whose value is "0" with other values id coming from database. and these IDs are using as the value of the particular drop down list. Now problem is this, I am using int data type in the database table, And I does not select any value from the table for drop down list but it add 0 to the table. And I do not need to add 0 in the database table. I also used NULL as default value for the column but it stored the value as 0. Please solve my problem, How i will store the value so that the value will not zero when i does not select anything in the select box. Thank you..
I found the solution for my question as I put the data type as int but NULLABLE and in php code I check the condition as if the value if blank the post the NULL value else the value will be whatever posted.
$insert_array['column_name']=$this->input->post('control_name')!==''?$this->input->post('control_name'):NULL;
So it will insert the NULL value if I does not select any value from the drop down list. Thank You
The int type has always 0 by default. If you want to leave empty (aka '') you can use char or varchar, text... string types This can break your server side program if it expect int