Reverse Tree Structure - locating parent records
I've got a table that contains file names and I've set up a query that generates an unordered list. The table has a record id (id) File Name and parentID. This all works perfectly.
Now I need to generate a serial number that reflects the position of the child in the table structure. Think if it as a file path. If documents was ID 4 and proposal was ID 9 and my-proposal was ID 15 Instead of documents/proposal/my-proposal I would to generate a serial number for myProposal like this: my-proposal SN 4.9.15 This shows me the lineage in the file tree and locates the document perfectly.
If my-proposal also had three children then they would show up in the directory structure like this:
If you're following me so far I have this code but it is giving me the children of the target and not the parents. IOW, I'm getting 188.8.131.52 instead of 5.9.15
** EDITED 4:25 Pacific Time ****
Just figured out part of the answer. The code above is working correctly. If you change the . in the HTML to <li /> and enclose the script in a <ul></ul> set you'll get a nice list of the files with indents. Changing the $parentID to 0 gives you the whole list so it makes sense that if I substitute the current page ID I'll get all of the children for that page.
Need another approach. I've been looking at a breadcrumb type of list generator to create my list. There's a start here:
Haven't been able to adapt it yet. If you have any other ideas please let me know.
do you realize most people wont even read a post title whos your daddy? proper titles get your more help, jsut saying.
I got this solved. It took a bit of searching but I finally got it. Here's the successful code. I hope it benefits someone else. It works well for a breadcrumb trail back up a PHP tree structure.
|All times are GMT +1. The time now is 10:19 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.