我需要做一些数学运算,但我似乎找不到办法。
我有下表,由此查询产生:
SELECT materii.id,
materii.materie,
GROUP_CONCAT(note.note) AS note,
GROUP_CONCAT(DISTINCT teza.`teza`) AS teza
FROM materii
LEFT JOIN teza ON materii.id = teza.id_materie
LEFT JOIN note ON materii.id = note.id_materie
LEFT JOIN elevi ON note.id_elev = elevi.cod_elev
LEFT JOIN luni ON note.`luna_nota`=luni.`id`
WHERE elevi.`cod_elev` = 1 AND luna_nota = 9
GROUP BY materii.id, materii.materie
ORDER BY materii.materie
我需要做类似的事情:
$notele = mysql_query($pentrumedie)
or die("Nu am gasit note in baza de date");
$numar_note = mysql_num_rows($notele);
if($numar_note==0)
{
}
else
{
while($rand2=mysql_fetch_array($notele))
{
$note1 = ($rand2['notele'] / $numar_note);
$medie_septembrie = ($note1 / $cate_note_sunt);
}
}
我需要为所有“note”做类似的事情,但如果有更多“note”,并且“teza”有值,则 $rand2['notele'] 需要是它们的总和,然后数学公式必须是:
(($rand2['notele'] / $numar_note) * 3 + teza) / 4
我尝试了一些 if 函数,但它们都不起作用....有什么想法吗?谢谢!!!