下面是代码:
$query = mysql_query("SELECT * FROM tablex");
if ($result = mysql_fetch_array($query)){
if ($result['column'] == NULL) { print "<input type='checkbox' />"; }
else { print "<input type='checkbox' checked />"; }
}
如果值是 NOT NULL
我仍然会得到未选中的框。我从上面做错了什么,应该 $result['column'] == NULL
工作吗?
有什么想法吗?
最佳答案
使用 is_null或 ===
运算符。
is_null($result['column'])
$result['column'] === NULL
关于PHP 检查 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1576243/