Skip to content
Advertisement

How can i reformat array this array?

So i have this database table

enter image description here

From that table i want to achievie this (My Expected result)

enter image description here

I don’t know the best way to handle this, so for now i create two query.

My first query

JavaScript

My second query

JavaScript

Below is result for my query

JavaScript

then my second query result is this

JavaScript

So, i want to merge both of the array , then i want to order total column desc, the second order is total2

Btw, i’m using mysql table. So how can i achieve my expected result (above), thanks in advance.

Advertisement

Answer

You can loop through your $results1 and $result2 and create a new array that contains data in your expected result format.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement