0
$ Grade和$ Remark總是以$ total的最後一個值(即where($ check_ss ==「Ss」))來計算,但我希望它能在每個if條件。我該怎麼做 例如,在第一種情況它會檔次和言論的價值同爲後續條件 還是我haveto包括內部的每個if語句在Switch語句設置中需要幫助
//Logic and Calc
if ($check_en=="En"){
$ot_en = $ent1 + $ent2 + $ent3 + $ent4 + $enexm;
$total = $ot_en;
}
if ($check_ms=="Ms"){
$ot_ms = $mst1 + $mst2 + $mst3 + $mst4 + $msexm;
$total = $ot_ms;
}
if ($check_ss=="Ss"){
$ot_ss = $sst1 + $sst2 + $sst3 + $sst4 + $ssexm;
$total = $ot_ss;
}
$ot= $ot_ms + $ot_ss + $ot_en;
switch ($total) {
case $total > 70:
$grade = "A";
$remark = "Excellent";
break;
case $total >= 60 && $total <= 69:
$grade = "B";
$remark = "Very Good";
break;
case $total >= 50 && $total <= 59:
$grade = "C";
$remark = "Good";
break;
case $total >= 45 && $total <= 49:
$grade = "D";
$remark = "Pass";
break;
case $total >= 40 && $total <= 44:
$grade = "E";
$remark = "Poor";
break;
case $total <= 39:
$grade = "F";
$remark = "Fail";
break;
}
if ($total == 0) {
$grade = "F";
$remark = "Fail";
'$ SQL1 =「INSERT INTO'records' VALUES(NULL, '$ SID', '英語', '$ ENT1', '$ ENT2', '$ ent3',「$ ent4 ','$ enexm','$ ot_en','$ gradesAlongTheWay ['En'] ['grade']','Poor')「; if(mysqli_query($ conn,$ sql1)){ echo「Values Inserted」; } else { echo「Failed」.mysqli_error($ conn); }' – 4Jean
嘗試插入數據庫時出現錯誤''grades gradesAlongTheWay ['En'] ['grade']' – 4Jean
它是否符合該條件?否則,該索引不會被設置。 – Ohgodwhy