Re: Nested database loops and completing an unordered list....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/02/2012 08:27 AM, Jay Blanchard wrote:
[snip]
Doesn't this SQL query return everything that has company_id set to 3
which would it not contain all the data from the other queries combined
into one large data set?
[/snip]

I could do that, I can return one large dataset for all of the columns
shown in the tiers array. I have to remove the DISTINCT's. When I return
that dataset in this case I return seven columns of data with the parent
being in the leftmost column and descending to the right. The goal with
the the recursive function was to get each descendant line so that it
could be formatted in a nested unordered list. So in the SQL below you
get 9 records. For each of the 9 records you could get any number of
children depending on which of the 9 you're looking at. Then for each of
those children you could get their descendants and so on.

I was doing it the long way at first, until a recursive function was
suggested. The problem that I was having there was formatting the <ul>'s
and <li>'s properly.

I'm not saying you should get rid of the recursive function calls, but rather, why not pull all your data in one SQL call, then use recursive functions on the returned array of data. It will save a little time by not hitting the DB on each function call too.


Now I feel as if I am really close to a better solution than the brute
force method. I may just be a little too frustrated to see what is a
simple answer.

Thanks for your help!


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux