How does php write a NULL value to the mysql field? _ PHP Tutorial

Source: Internet
Author: User
How does php write a NULL value to the mysql field ?. Problem: When modifying the house information, there is a field that is the total number of floors floorall, which is the int field. if you enter the value of this field when modifying the information, write the value to the database. Problem:

When modifying the house information, one field is the total floor count floorall, which is the int field and can be empty.
When modifying information, if the value of this field is entered, the value is written to the database. If no value is entered, NULL is written to the database.
How to implement it?

I wrote it like this.
If ($ floorall = '') {$ floorall = NULL ;}
$ Db-> query ("updata tabel set floorall = '$ floorall '");
The written value is 0 instead of NULL.

Answer:

Hello, please execute the following statement:

Updata tabel set floorall = null

When you modify the house information in the upper-right corner, there is a floorall field in the total floor number, which is an int field. if you enter this field when modifying the information, write the value to the database...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.