如果行为空,则回显默认文本,否则回显显示数据

I would like to display "Not Provided" if addition_1 is empty in the database and if it is not empty in the database I would like to display the data? I've tried several combination and can't see to figure out what I am missing.

<?php
if (empty($row[addition_1])) {
    echo "Not Provided";
} 
else {
    echo $row[addition_1];
}
?>

try adding quotes to your array key, like change:

$row[addition_1]

to

$row['addition_1']

One alternative would be to add this to your SQL with COALESCE instead:

SELECT COALESCE(addition_1, 'Not Provided')...

Just another option. This does assume addition_1 is NULL in the db...

In case it's blank and not NULL, then try this:

SELECT COALESCE(NULLIF(addition_1,''), 'Not Provided')...

Good luck.

I'm always using combination:

if (isset($row['addition_1']) && trim($row['addition_1']))

Remember, that you cannot according to documentation use any function in empty() function, that is why I'm using this. If you are 100% sure that addition_1 is always isset, you can skip that.