Current location: Hot Scripts Forums » Programming Languages » PHP » PHP multi-dimensional array sorting issue

PHP multi-dimensional array sorting issue

 
Prev Previous Post   Next Post Next
  #1  
Old 06-23-05, 08:25 PM
aqw aqw is offline
New Member
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
PHP multi-dimensional array sorting issue

I have this result set:

Code:
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).

Code:
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.
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex mysql sorting pb (Get cat_list from cids &pcids with 1 query, willing to pay) aqw PHP 1 06-23-05 08:02 PM
PHP Error Issue Chad PHP 2 05-08-05 05:28 PM
php chatscript colour issue Bantam PHP 13 09-21-04 11:41 AM
php or apache issue? lokey PHP 7 03-09-04 12:55 AM
linking to iframe not working :( j0d JavaScript 5 01-19-04 09:14 PM


All times are GMT -5. The time now is 09:09 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)