简体   繁体   中英

PHP MySQL print only empty column names from database row

$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;
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM