查找分数低于50的受试者,并在php中显示受试者名称



一个表格显示了学生在一个班级中各个科目的成绩。一些学生在一些核心科目上的成绩低于及格分数。

现在,在每个学生的成绩表中,我想显示他们重新参加了分数低于50(及格分数(的科目。

例如,一名学生的物理和化学成绩分别为45分和49分,低于这些科目的及格分数。他的成绩表应该写着";推荐用于物理学和化学中的RE-SIT";

这是我的if语句

<?php
if ($value->h_tot_score >= 90 && $value->h_tot_score <= 100) {
$result = 'PROMOTED TO THE NEXT CLASS';

} elseif ($value->h_tot_score >= 45 && $value->h_tot_score <= 49.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ';
} elseif ($value->h_tot_score >= 40 && $value->h_tot_score <= 44.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ';
} elseif ($value->h_tot_score >= 0 && $value->h_tot_score <= 39.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ';
}
?>

这是我对获得分数低于50的科目的查询

SELECT `subject_id` FROM `hscores_primary` WHERE `class_id` in (15,16,17) and `student_id=461` AND `h_tot_score` <= 49.99

结果是subject_id=79和34

如何在上面的if语句中自动显示或回显主题名称?

您可以执行LEFT JOIN。假设在subjects中保存主题名称的行被称为subject_name

SELECT h.subject_id, h.h_tot_score, s.subject_name 
FROM hscores_primary h 
LEFT JOIN subjects s
ON h.subject_id = s.id
WHERE h.class_id IN (15,16,17) 
AND h.student_id=461 

和php

<?php
if ($value->h_tot_score >= 90 && $value->h_tot_score <= 100) {
$result = 'PROMOTED TO THE NEXT CLASS';
} elseif ($value->h_tot_score >= 45 && $value->h_tot_score <= 49.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ' . $value->subject_name;
} elseif ($value->h_tot_score >= 40 && $value->h_tot_score <= 44.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ' . $value->subject_name;
} elseif ($value->h_tot_score >= 0 && $value->h_tot_score <= 39.99) {
$result= 'RECOMMENDED FOR RE-SIT IN ' . $value->subject_name;
}
?>

相关内容

  • 没有找到相关文章

最新更新