Referring to all empty MySQL fields

Let’s say there is a table with 25 fields, 16 of them have an empty value. How to process all fields with an empty value using php to set them to the same value, for example, there is no information?


Answer 1, authority 100%

$query = 'SELECT * FROM table';
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res)) {
     while(list($key,$value) = each($row)) {
        if(empty($value)) {
            $row[$key] = ' ';
        }
     }
     $data[] = $row;
}

Something like this…


Answer 2, authority 100%

while ($result = mysql_fetch_array($data)){
    foreach ($result as $v){
       if ($v=='') {
           echo " ";
       } else {    
           echo $v; //  
       }    
    }
}

But the downside is that the fields will be displayed in the order in which they appear in the base table.


Answer 3, authority 100%

SELECT ISNULL(field, ‘no info’) FROM table


Answer 4

Maybe it makes sense to do it using MySQL – which is faster in my opinion