have a SQL search which I’m looking through the results from.

I want to populate a new array based on some functions within each loop.

for example, if row one is class of 1997 and student ID 12, add an array with data to a master array called studentSummary

if my 3rd row is 1997 and student 12x, I update my data. Things that are totals increase by whatever the a amount is etc.

how can I do this check for an array with two keys essentially

    If all you are producing is a total per class, per student id, you can do this in the query by using - GROUP BY class, student_id You can then index/pivot the data when you fetch it, using first the class value, then the student id value as array indexes, e.g. $data['class']['student_id'] = ''total' -> $data[1997][12] = xxxx

    pbismad

    class isn’t in my DB is another look up in the loop. Hence needing to rebuild and assay

      You need to use a single join query. Running queries inside of loops is extremely inefficient.

        Write a Reply...