I have this result set:
title parentcat_ids base_title
ASP 12 ASP
Discs 12,10 ASP
Java 12,11 ASP
JSP 3 JSP
PHP 1 PHP
Books 1,5 PHP
XML 1,6 PHP
Ad management 1,7 PHP
Abraham's Report 1,7,13 PHP
XXL 1,7,14 PHP
Zimmick 1,7,14,15 PHP
Hattrick 1,7,14,16 PHP
Junkyfood 1,7,14,17 PHP
Programs 1,7,9 PHP
Ziggurat 1,7,9,18 PHP
Traffic scripts 1,8 PHP
XML's fall 4 XML's fall
...
And I want to have this result set: (I've delimited the rows to make them easier to see).
title parentcat_ids base_title
ASP 12 ASP
Discs 12,10 ASP
Java 12,11 ASP
JSP 3 JSP
PHP 1 PHP
Ad management 1,7 PHP
Abraham's Report 1,7,13 PHP
Programs 1,7,9 PHP
Ziggurat 1,7,9,18 PHP
XXL 1,7,14 PHP
Hattrick 1,7,14,16 PHP
Junkyfood 1,7,14,17 PHP
Zimmick 1,7,14,15 PHP
Books 1,5 PHP
Traffic scripts 1,8 PHP
XML 1,6 PHP
XML's fall 4 XML's fall
You have surely already noticed that the thing that needs to be done to the 1st result set is to sort the rows (belonging to a same parentcategory) with 'title'.
Suppose you got the first result set from the db. (I can't get any better result set from the DB. Please don't tell me I should have sorted it in the db first, it's just not possible).
Then create an array (multidimensional) simulating the 2nd result set. (With the help of mysql's sort functions etc.).
The real db has of course many more categories (around 5000).
I have tried longely but never succeeded 🙂
Thanks so much.