Skip to content
PHP Logo

How can isset be used in a SELECT query to check if a column is filled or not in PHP?

When using a SELECT query in PHP, you can use the isset() function to check if a specific column in the result set is filled or not. This can be useful when you want to handle cases where a column may be empty or null. By using isset() in conjunction with fetching the data from the result set, you can determine if the column has a value before processing it further.

php
// Assuming $result is the result set from a SELECT query
if(isset($result['column_name'])) {
    // Column is filled, do something with the value
    $value = $result['column_name'];
} else {
    // Column is empty or null
    // Handle this case accordingly
}