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 のより多くの結果に対して自動ステートメントを作成する方法です。
mysql select ではなく while ループで実行する必要があります。PHPラング。どうも。