PHP MySQL只打印数据库行中的空列名

时间:2010-10-21 08:10:54

标签: php sql mysql

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


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

我该怎么办?
感谢

1 个答案:

答案 0 :(得分:2)

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

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