sql – PHP MySQL print only empty column names from database row – Education Career Blog

$sql = "SELECT * FROM table";
$result = mysql_query($sql);


while($row = mysql_fetch_row($result)){
   // PRINT COLUMN NAMES WITH EMPTY VALUE
}

how can i do this?
thanks

,

$sql = "SELECT * FROM table";
$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result))
{
    foreach ($row as $columnName => $value)
    {
        if (empty($value))
        {
            echo $columnName;
        }
    }
}

Leave a Comment