Re: [PHP-DB] select with parentID field into multidimensional array?

2001-01-21 Thread nuitari

Well don't forget to use the order by and group by and where commands in
SQL
they could be quite useful in making a tree

Stephen wrote:
> 
> Im not putting the array data back intoi the db, it is just to structure
> the data coming out of the db before i create a tree like structure with
> it on the page
> The data going into the db will always be a simple ID name parentID. Its
> the neatest way to do it I can think of including using the array
> structure. I am imagining it is possible to implement a way to take a
> select * from table and format an array with all the data in a tree like
> structure within the array with one pass of the data, then on a single
> pass of the array write out the info in whatever tree like format i wish
> onto my page. If I work it out Ill be sure to post it :)
> 
> On Sun, 21 Jan 2001 [EMAIL PROTECTED] wrote:
> 
> > Date: Sun, 21 Jan 2001 15:50:16 -0500
> > From: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP-DB] select with parentID field into multidimensional
> > array?
> >
> > Hi,
> >
> > Maybe it would be better not to use a multidimentionnal array in a db.
> > You should create to additionnal columns that stores the ParentID
> > of the row.
> >
> > It's the easiest way to do it.
> >
> > Also you can create another table that would translate from
> > numbers to text, or just put the text.
> >
> >
> > Stephen wrote:
> > >
> > > I am having most of my problems because I am trying to do this walking
> > > through the data a single time, with the assumption any records parentID
> > > has an ID less than the child and therefore would already be populated in
> > > the array...
> > >
> > > On Sun, 21 Jan 2001, Stephen wrote:
> > >
> > > > Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST)
> > > > From: Stephen <[EMAIL PROTECTED]>
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP-DB] select with parentID field into multidimensional array?
> > > >
> > > > Hi
> > > >
> > > > I have a table which is set out like this
> > > >
> > > > ID name parentID
> > > >
> > > > I "select * from table" into $result.
> > > >
> > > > I then wish to walk through the result such that it creates a
> > > > multidimensional array sorted with children under parents. Here is a basic
> > > > eg.
> > > >
> > > > IDnameparentID
> > > > 1 books   0
> > > > 2 movies  0
> > > > 3 songs   0
> > > > 4 horror  1
> > > > 5 love1
> > > > 6 horror  2
> > > > 7 love2
> > > > 8 scifi   2
> > > > 9 IT  4
> > > >
> > > > etc
> > > >
> > > > I am trying to write a function that would then insert these into a
> > > > multidimensional array as such...
> > > >
> > > > $array[1] = "books";
> > > > $arary[1][4] = "horror";
> > > > $array[1][4][9] = "IT";
> > > >
> > > > etc, so I could pull them out into a select dropdown list nicely sorted.
> > > >
> > > > I am not sure how to write an array function with an unlimited number of
> > > > levels. If someone could help out it would be greatly appreciated.
> > > >
> > > > Thanks
> > > > Stephen
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > PHP Database Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > > email: meridian at tha net
> > > web: meridian.on.tha.net
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> email: meridian at tha net
> web: meridian.on.tha.net
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] select with parentID field into multidimensional array?

2001-01-21 Thread Stephen

Im not putting the array data back intoi the db, it is just to structure
the data coming out of the db before i create a tree like structure with
it on the page
The data going into the db will always be a simple ID name parentID. Its
the neatest way to do it I can think of including using the array
structure. I am imagining it is possible to implement a way to take a
select * from table and format an array with all the data in a tree like
structure within the array with one pass of the data, then on a single
pass of the array write out the info in whatever tree like format i wish
onto my page. If I work it out Ill be sure to post it :)

On Sun, 21 Jan 2001 [EMAIL PROTECTED] wrote:

> Date: Sun, 21 Jan 2001 15:50:16 -0500
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] select with parentID field into multidimensional
> array?
> 
> Hi,
> 
> Maybe it would be better not to use a multidimentionnal array in a db.
> You should create to additionnal columns that stores the ParentID
> of the row.
> 
> It's the easiest way to do it.
> 
> Also you can create another table that would translate from 
> numbers to text, or just put the text.
> 
> 
> Stephen wrote:
> > 
> > I am having most of my problems because I am trying to do this walking
> > through the data a single time, with the assumption any records parentID
> > has an ID less than the child and therefore would already be populated in
> > the array...
> > 
> > On Sun, 21 Jan 2001, Stephen wrote:
> > 
> > > Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST)
> > > From: Stephen <[EMAIL PROTECTED]>
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP-DB] select with parentID field into multidimensional array?
> > >
> > > Hi
> > >
> > > I have a table which is set out like this
> > >
> > > ID name parentID
> > >
> > > I "select * from table" into $result.
> > >
> > > I then wish to walk through the result such that it creates a
> > > multidimensional array sorted with children under parents. Here is a basic
> > > eg.
> > >
> > > IDnameparentID
> > > 1 books   0
> > > 2 movies  0
> > > 3 songs   0
> > > 4 horror  1
> > > 5 love1
> > > 6 horror  2
> > > 7 love2
> > > 8 scifi   2
> > > 9 IT  4
> > >
> > > etc
> > >
> > > I am trying to write a function that would then insert these into a
> > > multidimensional array as such...
> > >
> > > $array[1] = "books";
> > > $arary[1][4] = "horror";
> > > $array[1][4][9] = "IT";
> > >
> > > etc, so I could pull them out into a select dropdown list nicely sorted.
> > >
> > > I am not sure how to write an array function with an unlimited number of
> > > levels. If someone could help out it would be greatly appreciated.
> > >
> > > Thanks
> > > Stephen
> > >
> > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > 
> > email: meridian at tha net
> > web: meridian.on.tha.net
> > 
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

email: meridian at tha net
web: meridian.on.tha.net


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] select with parentID field into multidimensional array?

2001-01-21 Thread nuitari

Hi,

Maybe it would be better not to use a multidimentionnal array in a db.
You should create to additionnal columns that stores the ParentID
of the row.

It's the easiest way to do it.

Also you can create another table that would translate from 
numbers to text, or just put the text.


Stephen wrote:
> 
> I am having most of my problems because I am trying to do this walking
> through the data a single time, with the assumption any records parentID
> has an ID less than the child and therefore would already be populated in
> the array...
> 
> On Sun, 21 Jan 2001, Stephen wrote:
> 
> > Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST)
> > From: Stephen <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] select with parentID field into multidimensional array?
> >
> > Hi
> >
> > I have a table which is set out like this
> >
> > ID name parentID
> >
> > I "select * from table" into $result.
> >
> > I then wish to walk through the result such that it creates a
> > multidimensional array sorted with children under parents. Here is a basic
> > eg.
> >
> > IDnameparentID
> > 1 books   0
> > 2 movies  0
> > 3 songs   0
> > 4 horror  1
> > 5 love1
> > 6 horror  2
> > 7 love2
> > 8 scifi   2
> > 9 IT  4
> >
> > etc
> >
> > I am trying to write a function that would then insert these into a
> > multidimensional array as such...
> >
> > $array[1] = "books";
> > $arary[1][4] = "horror";
> > $array[1][4][9] = "IT";
> >
> > etc, so I could pull them out into a select dropdown list nicely sorted.
> >
> > I am not sure how to write an array function with an unlimited number of
> > levels. If someone could help out it would be greatly appreciated.
> >
> > Thanks
> > Stephen
> >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> email: meridian at tha net
> web: meridian.on.tha.net
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] select with parentID field into multidimensional array?

2001-01-21 Thread Stephen

I am having most of my problems because I am trying to do this walking
through the data a single time, with the assumption any records parentID
has an ID less than the child and therefore would already be populated in
the array...


On Sun, 21 Jan 2001, Stephen wrote:

> Date: Sun, 21 Jan 2001 23:49:13 +1100 (EST)
> From: Stephen <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] select with parentID field into multidimensional array?
> 
> Hi
> 
> I have a table which is set out like this
> 
> ID name parentID
> 
> I "select * from table" into $result.
> 
> I then wish to walk through the result such that it creates a
> multidimensional array sorted with children under parents. Here is a basic
> eg.
> 
> IDnameparentID
> 1 books   0
> 2 movies  0
> 3 songs   0
> 4 horror  1
> 5 love1
> 6 horror  2
> 7 love2
> 8 scifi   2
> 9 IT  4
> 
> etc
> 
> I am trying to write a function that would then insert these into a
> multidimensional array as such...
> 
> $array[1] = "books";
> $arary[1][4] = "horror";
> $array[1][4][9] = "IT";
> 
> etc, so I could pull them out into a select dropdown list nicely sorted.
> 
> I am not sure how to write an array function with an unlimited number of
> levels. If someone could help out it would be greatly appreciated.
> 
> Thanks
> Stephen
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

email: meridian at tha net
web: meridian.on.tha.net


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]