I have updated certain field in my database & that field has default value as NULL. How can I again fill NULL if field is emptied or deleted. As during this updation blank value is filled in database and of course that is not NULL. Is filling NULL instead of blank value good?
Using php how can I do that? Suppose I have condition if code
if(!empty($photo))
{ $a in database;
}
But in this condition if $photo is empty it will fill blank value of $a… Let me know to fill NULL in database.
You just have to write
null, and not an empty value, to your database.You SQL query would look like this :
instead of :
To switch between those two queries, you might need some condition in your PHP code, depending on how it’s organized ; maybe like this :
Note that if you have no value to store for a row in your database, you might also want to just delete that row :
Of course, it’s up to you to determine which is the best for your application : a row with a NULL value, or no row.