by Dinesh Thakur Category: PHP (Hypertext Preprocessor)

It is useful to verify that all fields are NULL in MYSQL to query data from a database so they can be treated differently from fields with numeric values ​​or text. NULL indicates an unknown value, which is different from a default value, such as 0 or ' '. You can use the PHP function "is_null" to tell if a returned MYSQL field is NULL or not.

1. Open your PHP source code in a text editor such as Notepad.

2. Use the "mysql_query (query)" function to send a query to the active MYSQL database. For example, "$result = mysql_query ("Select row from Tname");".

3. Use the "mysql_fetch_assoc ($result)" function within a "while" loop to fetch rows from the MYSQL result. For example, "while ($row ​​= mysql_fetch_assoc ($result)) ".

4. Use the "is_null (variable)" inside "while" loop to determine if a field of a returned row has a NULL value. For example, if (is_null ($row ["LName"])) {echo "is null";}} "will print" is null "values ​​for any " row " which are NULL.

5. Save the PHP below file and run.

<!DOCTYPE html>

   $result = mysql_query ("Select row of Tname");
   while ($row ​​= mysql_fetch_assoc ($result))
       if (is_null ($row ["LName"]))
         {echo "is null";}

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.