Table with data:
id score inputid
1 1 1
2 4 1
3 3 1
4 1 2
5 2 2
6 3 5
7 1 6
8 1 6
while ($stmt_score->fetch())
{
if($bind_inputid == '1') $array['score'][0] += $bind_score;
if($bind_inputid == '2') $array['score'][1] += $bind_score;
if($bind_inputid == '5') $array['score'][2] += $bind_score;
if($bind_inputid == '6') $array['score'][3] += $bind_score;
}
如上所述,我想对具有特定 ID 的所有结果求和。但是由于会有更多的 $bind_inputid ID,我的问题是,如何为 ID 的更多结果生成自动语句?
它必须在 while 循环中完成,而不是使用 mysql select。PHP 朗。谢谢。