Home >php教程 >php手册 >php如何向mysql字段中写入NULL的值?

php如何向mysql字段中写入NULL的值?

PHP中文网
PHP中文网Original
2016-06-13 11:38:093127browse

php如何向mysql字段中写入NULL的值?

问题:

修改房屋信息时,有一个字段是楼层总数floorall,是int字段,允许空
当修改信息时,如果输入了这个字段的值,则向数据库中写入值,如果没有输入值,则向数据库中写入NULL
怎么实现?

我是这样写的

if($floorall==''){$floorall=NULL;} 
$db->query("updata tabel set floorall ='$floorall'");

回答:

你好,请执行以下语句:

updata tabel set floorall = null

以上就是php如何向mysql字段中写入NULL的值?的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
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