tommy2shoes Posted April 9, 2011 Share Posted April 9, 2011 Hi I have a table (applicant) that has a number of fields but included are: applicantid party1 party2 party3 party4 party5 Any number of these party entries could have data in them but I need to know, for any specific applicantid, the count of how many non null entries there are. I can't find a way to do it. Does anyone have any ideas. Many thanks Link to comment https://forums.phpfreaks.com/topic/233188-counting-for-specific-fields-that-arent-null/ Share on other sites More sharing options...
ted_chou12 Posted April 9, 2011 Share Posted April 9, 2011 $array =array( "ap1" => "1", "ap2" => "", "ap3" => "0", "ap4" => "", "ap5" => "test"); $i=0; foreach ($array as $key => $val) { if ($val != "") {$i++;} } echo "number of non null entries is $i"; ? Ted Link to comment https://forums.phpfreaks.com/topic/233188-counting-for-specific-fields-that-arent-null/#findComment-1199201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.