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;
}
As stated above I want to sum all results with specific ID. But since there will be more $bind_inputid ID’s, my question is, how to make automatic statements for more results of an Id’s ?
It has to be done in while loop not with mysql select.
PHP Lang.
Thx.
Assume your result is sorted by
inputid: