How to write NULL value to mysql field in php? _PHP Tutorial

WBOY
Release: 2016-07-21 14:55:43
Original
1170 people have browsed it

Question:

When modifying the house information, there is a field which is the total number of floors, floorall, which is an int field and is allowed to be empty.
When modifying the information, if the value of this field is entered, the value will be written to the database. If no value is entered, the value will be written to the database. , how to write NULL
to the database?

This is what I wrote
if($floorall==''){$floorall=NULL;}
$db->query("updata tabel set floorall ='$floorall' ");
But the value written in this way is 0 instead of NULL

Answer:

Hello, please execute the following statement:

updata tabel set floorall = null

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364368.htmlTechArticleQuestion: When modifying house information, there is a field that is the total number of floors floorall, which is an int field and is allowed to be empty when modifying the information. , if the value of this field is entered, the value is written to the database...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template