Reply to Threading articles from a SQL DB using PHP

Your name:

Reply:


Posted by BN on 09/18/05 21:47

I have a table with (for brevity) 2 columns. RecID and ParentID.

All absolute or generation 0 PARENT records will have a ParentID of 0
(zero) but their children will have their parentID pointed to an
existing parent's RecID (a parent of any generation).

I want to list out the parents with all their children
and grandchildren under them and then start listing the next parent and
all the children and grand children under them etc.

example

RECID ParentID
PARENT 1 0
child 2 1 child of p1
child 6 1 child of p1
child 4 6 child of child
child 5 4 child of child of child
PARENT 3 0 next parent of gen 0
child 7 3 child of p3 or RecID 3


etc.. I want to list it in that order.

When I select it of the PostgreSQL database, I get records but not in
the above order. I have to load it into a temporary array and then put
it into that threaded ordered. I am using PEAR:DB for access to the
PGSQL database.

How do I do this? Arrays? Maps?

Can elements in maps be listed through iteration?

Are there processor efficient ways to do this?

Any help would be appreciated!!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация