我需要整理一个方法,以便我可以量化用户填充的行数.
例如:
User Name Age Country Gender Height 1 Mike 34 USA Male 6 2 Bill 23 CA 5 3 Jane 31 USA
在上面的示例中,我想查询数据库并返回一个值,该值将反映用户记录的完成程度.如:
User 1 = 100% complete User 2 = 80% complete User 3 = 60% complete
$result = MysqL_query('SELECT * FROM `MyTable`'); while($row = MysqL_fetch_row($result)){ $empty_count = 0; $count = count($row); for($i = 0; $i < $count; $i++) if($row[$i] === '' || $row[$i] === 'NULL') $empty_count++; echo 'User '.$row[0].' = '.((int)(100*(1-$empty_count/($count-1)))).'% complete'; }