This code loops through a mysql table and prints out empty/null fields. It however prints the array values and the keys like this
Array (
[0] => Field "dob" on entry "1" is empty/null
[1] => Field "user_name" on entry "7" is empty/null
)
How do I print something like this field "dob" on entry "1" is empty/null
$sql = "SELECT * FROM userinfo";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
foreach($row as $key => $field) {
if(empty($field)) {
$emptyFields[] = sprintf('Field "%s" on entry "%d" is empty/null', $key, $row['userid']);
}
}
}
print_r($emptyFields);
echo implode('<br>', $emptyFields);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With