我有一张表格,显示用户在布尔中有哪些拼图... ...
client | col A | col B | col C | col D | col E
john Doe | 1 | 1 | 0 | 0 | 1
Jane Deer| 0 | 1 | 0 | 1 | 0
我可以从Db中获取该行。
// Get puzzle pieces
$requery = "SELECT * FROM puzzletbl WHERE client_id = '$client_id' LIMIT 1";
$reresult = mysqli_query($dbc, $requery);
// Check for missing pieces
if ($reresult){
while ($row = mysqli_fetch_array($reresult, MYSQLI_ASSOC)) {
$status = array("NO", "OKAY");
} // END WHILE
} // END IF REresult
我只需要获得那些带有0的列(它们是缺失的部分),所以我可以将其添加到电子邮件中,让他们知道缺少的内容。
答案 0 :(得分:0)
循环遍历$row
,并测试该值是否为0
。
while ($row = mysqli_fetch_array($reresult, MYSQLI_ASSOC)) {
$zero_cols = array();
foreach ($row as $col => $val) {
if ($col == "client") {
$client = $val;
} elseif ($val == 0) {
$zero_cols[] = $col;
}
}
// Send mail to $client with $zero_cols info
}