Re: Tree array



I'm not sure if you're looking for the SQL statement to pull the info
into an array, or if you'
re not sure how to build the array, but I have one suggestion, just
based on the table structure.

Why not set up the table with...

ID
PARENT_ID
PATH
TITLE

Then, if your data to produce...
Home > Products > Knowledge
would look more like..

ID PARENT_ID PATH TITLE
1 0 /index.php Home
2 1 /products.php Products
3 2 /knowledge.php Knowledge

If the PARENT_ID is 0 it's a root level (depth of 0 in your example).
The order is built in when you do the query.

To get the info into an array, you could do a recursive query up the
tree until you get to PARENT_ID=0. Then sort the array in reverse to
display.

I don't have source worked up, but I think that logic would work.

Sorry if I'm going in a different direction. If you post more info, I
can try to help more later if necessary.

.



Relevant Pages

  • Re: Passing values from a multi-select list to a MySQL query using PHP
    ... John wrote: ... I have these items loaded into an array, and use this code to put them ... it is passed into my sql statement it will work properly? ... I'd suggest putting single quotes around the values before imploding the array, ...
    (comp.lang.php)
  • Re: Import from finance.yahoo.com
    ... containing tables of stock statistics, it runs down the page and pulls the ... You could do the same thing using the 'find' command and I guess not have to ... Using the find command might also allow you to pull in the whole page (using ... an array and then looping through the array. ...
    (microsoft.public.excel.programming)
  • Re: drive failure during rebuild causes page fault
    ... Pull a drive and rebuild onto hot spare. ... but not page fault when it's not / ... what's the story with the new array appearing when you ...
    (freebsd-stable)
  • Re: not enough storage... error using GetRows
    ... After the rows were dumped into the array the memory used was ~500MB but the ... I did a select into using the sql statement in question and ran a sproc to ... I'd say it's almost certainly a resource issue. ... > of a row in this data, to make a scientiffic estimate for memory consumption ...
    (microsoft.public.vb.database.ado)
  • Re: Cant reverse array of Integers ?
    ... as I'm running out of hair to pull out :-( ... The PixLine will typically contain a single value of 255 at a random ... glaringly obvious to a knowledgable delphi wizard:P The array is ...
    (alt.comp.lang.borland-delphi)