Jump to content

HorseFace

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

HorseFace's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks so much guys, array_keys did the trick. Really appreciate your help! /Eric
  2. Hi, Thanks for your reply, Fyorl: The data and hierarchy will be placed in the same table. I will feed this information to a Tree component in flex as xml, but formating a php array into an xml is not a problem. Barand: I have previously managed to create an XML using a similar function but later realized that this will only work if the rows in the database are sorted in a specific way (child node always directly after its parent node). The goal is to be able to move parents and child nodes freely (like in windows explorer for example) meaning that a node with id = 2 could become the child of node with id = 23 for example. This would mean that during the foreach loop nodes might need to be skipped temporarelly until their parents are created. One option would be to recreate nodes every time there is a change in the table, but this could be expensive with hundreds of nodes. Now im just babbling, maybe someone has some ideas :-) I guess im trying to recreate windows explorer :-S. Thanks again for your reply /Eric
  3. Hi Everyone, I need some help transforming a database table into an XML or Array. I am using an adjacency model for my database, meaning i have a structure similar to the following: Project Id Parent Id 1 null 2 1 3 1 4 2 5 3 6 5 From that hierarchy i wish to get something like this: <Projects> <Project id="1"> <Project id="2"> <Project id="4"/> </Project> <Project id="3"> <Project id="5"> <Project id="6"/> </Project> </Project> </Project> </Projects> which i will then use to feed a Tree Component in my UI (made in Flash). What would be necessary would be some kind of recursive function to create this XML/Array I'm guessing. I am open to suggestions including changing the database model (for example using a right/left node model instead of adjacency). The nodes will constantly be changed (like a file system) so i will need to take the model's performance during editing into consideration. I am using a mySQL database and PHP5. I would really appreciate any help/tips/ideas that anyone might have in this area. Thanks in advance /Eric
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.