I have a PHP array which has several different fields. For some of the rows id and name is the same and the rest of data is different.
I want to display the data in an HTML table without listing the duplicated data more than once. I realize that I can use colspan/rowspan to merge the table cells, but I’m not sure how to do counts/sums based on the matching values.
Below is how my table looks like :
Id Name value1 value2 value3
2312 ABC test test2 test3
2312 ABC XYz 122 211
2455 XYZ val11 val2 val3
Any help will be appreciated.
I can suggest you to create a new multidimensional array and merge the arrays that have the same ID … the rest will be easy. Take a look at the example I’ve made
the example in CodePad