I have some fairly complex MySQL queries that return about 30 fields. I am doing some conditional formatting for a report and need to determine if any of those fields are empty across all of the results. I know how to check on a per row basis, but I need to determine if an entire "column" is empty after returning the results.
I'm using PHP 5.2 and simple HTML to generate the reports.
Something like this?
$results = mysql_fetch_array($resource);
$columnEmpty = checkEmptyColumn($results, "column_name"); // returns true if empty
function checkEmptyColumn($array, $columnName){
foreach ($array as $arr){
if(!empty($arr[$columnName])) return false;
}
return true;
}
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.