สอบถาม เรื่อง การนับค่าที่ได้จาก echo ซึ่งเป็นข้อมูลที่ได้จากการประมวลผลเรียบร้อยแล้ว
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบถาม เรื่อง การนับค่าที่ได้จาก echo ซึ่งเป็นข้อมูลที่ได้จากการประมวลผลเรียบร้อยแล้ว
สอบถาม เรื่อง การนับค่าที่ได้จาก echo ซึ่งเป็นข้อมูลที่ได้จากการประมวลผลเรียบร้อยแล้ว
Copy
สอบถามเกี่ยวกับ การนับจำนวนข้อมูลที่ผ่านการคิวรี่ จากหลายตาราง มาทำการคำนวณ และแสดงผลออกมาecho แล้ว จะมีวิธีการนับอย่างไรค่ะ
อันนี้เป็น code
อันนี้เป็น code
include ('config.php');
$strSQL1=" SELECT tbp_answer.*,tb_answer.*,tbs_answer.*,tb_students.*
,tb_teacher.*,
SUM(IF(FIND_IN_SET(tbp_answer.id_question,'3,8,13,16,24') ,tbp_answer.score_p+tb_answer.score+tbs_answer.score_s,0)) as all1,
SUM(IF(FIND_IN_SET(tbp_answer.id_question,'5,7,12,18,22') ,tbp_answer.score_p+tb_answer.score+tbs_answer.score_s,0)) as all2,
SUM(IF(FIND_IN_SET(tbp_answer.id_question,'2,10,15,21,25') ,tbp_answer.score_p+tb_answer.score+tbs_answer.score_s,0)) as all3,
SUM(IF(FIND_IN_SET(tbp_answer.id_question,'6,11,14,19,23') ,tbp_answer.score_p+tb_answer.score+tbs_answer.score_s,0)) as all4,
SUM(IF(FIND_IN_SET(tbp_answer.id_question,'1,4,9,17,20') ,tbp_answer.score_p+tb_answer.score+tbs_answer.score_s,0)) as all5
FROM tbp_answer
LEFT JOIN tb_answer
ON tbp_answer.id_student =tb_answer.id_student
AND tbp_answer.id_question=tb_answer.id_question
JOIN tbs_answer
ON tb_answer.id_student =tbs_answer.id_student
AND tb_answer.id_question=tbs_answer.id_question
JOIN tb_students
ON tbs_answer.id_student =tb_students.id_student
JOIN tb_teacher
ON tbp_answer.id_teacher =tb_teacher.id_teacher
WHERE tb_teacher.username = '".$_SESSION['username']."'
GROUP BY tb_students.id_student ";
$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
while($row = mysql_fetch_array($objQuery1)) {
?>
<tr>
<td align="center"><?= $row['id_student']; ?></td>
<td><?= $row['Name']; ?></td>
<td align="center">
<? if ($row[sex_s]=="1"){
echo "ชาย";
} elseif($row[sex_s]=="2"){
echo "หญิง";
}?>
</td>
<td align="center"><?echo number_format($a1=$row['all1']/3, 2, '.', ''); ?>
<? if ($a1<=3){
echo "= ปกติ";
}elseif($a1<=4){
echo "= เสี่ยง";
}elseif($a1>4){
echo "= ปัญหา";
}
?>
</td>
<td align="center"><?echo number_format($a2=$row['all2']/3, 2, '.', ''); ?>
<? if ($a2<=3){
echo "= ปกติ";
}elseif($a2<=4){
echo "= เสี่ยง";
}elseif($a2>4){
echo "= ปัญหา";
}
?>
</td>
<td align="center"><?echo number_format($a3=$row['all3']/3, 2, '.', ''); ?>
<? if ($a3<=5){
echo "= ปกติ";
}elseif($a3<=6){
echo "= เสี่ยง";
}elseif($a3>6){
echo "= ปัญหา";
}
?>
</td>
<td align="center"><?echo number_format($a3=$row['all3']/3, 2, '.', ''); ?>
<? if ($a4<=5){
echo "= ปกติ";
}elseif($a4<=6){
echo "= เสี่ยง";
}elseif($a4>6){
echo "= ปัญหา";
}
?>
</td>
<td align="center"><? echo number_format( $a=$row['all1']/3+$row['all2']/3+$row['all3']/3+$row['all4']/3, 2, '.', ''); ?>
<? if ($a<=15){
echo "= ปกติ";
}elseif($a<=17){
echo "= เสี่ยง";
}elseif($a>17){
echo "= ปัญหา";
}
?>
</td>
<td align="center"><?echo number_format($a5=$row['all5']/3, 2, '.', ''); ?>
<? if ($a5<=3){
echo "= ไม่มีจุดแข็ง";
}elseif($a5>4){
echo "= เป็นจุดแข็ง";
}
?>
</td>
</tr>
<?}?>
</table>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ