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


PHP multi-dimensional array sorting issue

Reply
  #1 (permalink)  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-24-05, 05:21 AM
aqw aqw is offline
New Member
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
anyone knows?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-25-05, 12:09 AM
jordie jordie is offline
Wannabe Coder
 
Join Date: Jun 2005
Posts: 179
Thanks: 0
Thanked 0 Times in 0 Posts
Whats the difference between the two PHP groups?

so you want it in an array like:
Code:
array => group01 => 0 => title               => ASP
                         parentcat_ids  => 12
                         base_title       => ASP
                   1 => title               => Discs
                         parentcat_ids  => 12,10
                         base_title       => ASP
                   2 => title               => Java
                         parentcat_ids  => 12,11
                         base_title       => ASP
        group02=> 0 => title               => JSP
                         parentcat_ids  => 3
                         base_title       => JSP
etc etc ????????
__________________
Jordie Bodlay
php, mysql, postgres
css, xhtml
graphics, design
email me: jb2386@hotmail.com for any programming needs.

Last edited by jordie; 06-25-05 at 12:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are On

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:44 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.