I have an array having two fields, total minutes and cost of teacher (I have teacher id) and clients. I am showing my data in tabular form. If there are more than 1 records of same teacher then I have to add new array element of sum of total minutes and cost just below but doesn't show not if only have one record. Below is the my array.

Array
(
    [0] => Array
        (
            [cid] => 143265
            [type] => private_tuition
            [teacher_name] => Brent Gardner
            [teacherId] => 137
            [school_name] => Liv Gussing
            [month_year] => Mar 17
            [starttime] => 05:00 PM
            [endtime] => 06:30 PM
            [amount] => 120
            [totalMins] => 360
            [hoursMins] => 6hr 0mins 
            [amount2] => 120
        )

    [1] => Array
        (
            [cid] => 143267
            [type] => private_tuition
            [teacher_name] => Brent Gardner
            [teacherId] => 137
            [school_name] => Eleanor Bertrand
            [month_year] => Mar 17
            [starttime] => 04:00 PM
            [endtime] => 05:00 PM
            [totalMins] => 240
            [hoursMins] => 4hr 0mins
            [amount2] => 70         
        )

    add an array element here having sum of totalMins and amount2

    [2] => Array
        (
            [cid] => 141290
            [type] => private_tuition
            [teacher_name] => Ching Ku
            [teacherId] => 87
            [school_name] => Astrid De Menezes
            [month_year] => Mar 17
            [starttime] => 09:00 AM
            [endtime] => 10:00 AM
            [totalMins] => 240
            [hoursMins] => 4hr 0mins 
            [amount2] => 50
        )

    no new element  

    [3] => Array
        (
            [cid] => 149989
            [type] => private_tuition
            [teacher_name] => David Dong
            [teacherId] => 86
            [school_name] => Amanda Tromans
            [month_year] => Mar 17
            [starttime] => 02:00 PM
            [endtime] => 03:30 PM
            [totalMins] => 180
            [hoursMins] => 3hr 0mins 
            [amount2] => 30
        )

    no new element  

    [4] => Array
        (
            [cid] => 149108
            [type] => private_tuition
            [teacher_name] => Eszter Aliz Odor
            [teacherId] => 174
            [school_name] => Sonata Rapalyte
            [month_year] => Mar 17
            [starttime] => 05:00 PM
            [endtime] => 06:00 PM
            [totalMins] => 60
            [hoursMins] => 1hr 0mins
            [amount2] => 65         
        )

    no new element  

    [5] => Array
        (
            [cid] => 139582
            [type] => private_tuition
            [teacher_name] => Gina Wang Luis
            [teacherId] => 19
            [school_name] => Graeme Aarons
            [month_year] => Mar 17
            [starttime] => 11:20 AM
            [endtime] => 12:00 PM
            [totalMins] => 120
            [hoursMins] => 2hr 0mins 
            [amount2] => 75.50
        )

    [6] => Array
        (
            [cid] => 139583
            [type] => private_tuition
            [teacher_name] => Gina Wang Luis
            [teacherId] => 19
            [school_name] => Sonja Ballingal (Peter)
            [month_year] => Mar 17
            [starttime] => 12:00 PM
            [endtime] => 12:40 PM
            [totalMins] => 120
            [hoursMins] => 2hr 0mins 
            [amount2] => 100
        )

    add an array element here having sum of totalMins and amount2

    and so on....

)
Member Avatar for diafol

SHow the SQL you're using and the table schemas

Above array is final result I have processed. I have to used above array.

Member Avatar for diafol

Why?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.