php - Generating hirarchical structure out of a flat table -


main question: efficient way transform flat table tree hierarchical structure ?

context: bit rusted , don't know if should handled on sql, php or javascript (kendo ui) side !

for kendo treeview (hierachicaldatasource), must export json encoded tree structure table made single select multiple joins multiple tables... generates huge table of following logical structure:

source table goal group "date", "client", "employee" , list "events". need structure one:

desired tree structure flat table guess best series of php loops ?... code ?

thanks !

try php code:

$result = array(); foreach($data $row) {     $date = $row['date'];     $employee = $row['employee'];     $client = $row['client'];     $event = $row['event'];      $result[$date][$client][$employee][] = $event; } 

i suppose $data through simple query before code.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -