I am extracting information from a database, and am not too hot on mysql, before i spend hours messing about with various arrays and whatnot, I was wondering if anybody knows of a simple and painless way of ordering the information retrieved in a particular way..
The database currently looks like this:
Code: Select all
ID | name | parentid
----------------------------------------------------------------
31 | ultrachild | 30
30 | achild | 28
28 | toplevel | 0
32 | notherchild | 28thus, "ultrachild 's" parent is "achild", "achild's" parent is "toplevel", "notherchild's" parent is also "toplevel",
or graphically it is:
Code: Select all
. toplevel
|
achild notherchild
|
ultrachildCode: Select all
toplevel
achild
ultrachild
notherchildim finding this somewhat confusing - im hoping theres a nice simple way of doing this in mysql, failing this, does anybody know how best to go about this!
thanks in advance
bob