• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » PHP » How to Checking MySQL NULL values with PHP
Next →
← Prev

How to Checking MySQL NULL values with PHP

By Dinesh Thakur

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> 
<html>
<body>
  <?php
   $result = mysql_query ("Select row of Tname");
   while ($row ​​= mysql_fetch_assoc ($result))
     {
       if (is_null ($row ["LName"]))
         {echo "is null";}
     }
 ?>
</body>
</html>

You’ll also like:

  1. MySql Null Condition in Java Servlet
  2. Which bitwise operator is suitable for checking whether a particular bit is ON or OFF
  3. How many Types of Comments are there in PHP
  4. PHP Constants Types
  5. PHP Cookies
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

PHP Tutorials

PHP Tutorials

  • PHP - Home
  • PHP - Features
  • PHP - Magic Methods
  • PHP - Imagefilter
  • PHP - Arrays Numeric
  • PHP - Sessions
  • PHP - Forms Processing
  • PHP - clone()
  • PHP - Cookies
  • PHP - Variable Types
  • PHP - First program
  • PHP - call()
  • PHP - Iterator interface
  • PHP - Imports files
  • PHP - Exception Handling
  • PHP - set() and get()
  • PHP - Install MAMP
  • PHP - Functions
  • PHP - Constants Types
  • PHP - Comments Types
  • PHP - OOP's
  • PHP - OOps Use
  • PHP - PHP Code & Redirect 301
  • PHP - Control structures
  • PHP - Abstract Classes
  • PHP - Control structures
  • PHP - Classes
  • PHP - MySQL NULL values
  • PHP - Methods Visibility
  • PHP - Operator Types
  • PHP - Short tags Not use
  • PHP - Object and class
  • PHP - Secure Passwords

Other Links

  • PHP - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW