我想使這個表表顯示,而不是零
! ID ! A ! B ! C ! D ! average !
-------------------------------------------------------
! 01 ! ! 0 ! 10 ! ! 5 !
! 02 ! ! ! ! ! !
! 03 ! 0 ! 0 ! ! 0 ! 0 !
我用這個函數空值
\t
if ($A == "") {$countA="0";} else { $countA = "1"; }
if ($B == "") {$countB="0";} else { $countB = "1"; }
if ($C == "") {$countC="0";} else { $countC = "1"; }
if ($D == "") {$countD="0";} else { $countD = "1"; }
$sum \t \t = ($A + $B + $C + $D);
$ceksum =($countA + $countB + $countC + $countD);
\t \t if ($ceksum == "0") {
$average="";
\t \t \t } else { $average = $sum/$ceksum; }
and php that i use to call the data is
echo ($averageled4amatt4h=="")?'':round($averageled4amatt4h,1);
但表所示THI小號的結果。(在平均空數據時零是唯一的值)
! ID ! A ! B ! C ! D ! average !
-------------------------------------------------------
! 01 ! ! 0 ! 10 ! ! 5 !
! 02 ! ! ! ! ! !
! 03 ! 0 ! 0 ! ! 0 ! !
我應該怎麼辦?我還在學習編碼...
它想出了平均零點所有空數據(數據02的平均值爲零,但數據03爲空)我想要相反的 –