On Mar 1, 2012, at 6:36 PM, Jay Blanchard wrote:
> [snip]…stuff…[/snip]
>
> I am getting close, but I am also getting frustrated. I probably need to walk
> away for a bit.
>
> I have an array of tiers….
>
> Array
> (
> [0] => TIER1DATA
> [1] => TIER2DATA
> [2] => TIER3DATA
> [3] => BUSTIER1DATA
> [4] => BUSTIER2DATA
> [5] => BUSTIER3DATA
> [6] => BUSTIER4DATA
> )
> Each of the tiers which represent parents in children in pairs. TIER1DATA is
> the parent of TIER2DATA, etc. representing 7 columns of data. Here is my code
> so far - any insight would be valuable and extremely appreciated by me.
>
> function display_children($i, $child) {
> global $dbc;
> global $tierArray;
> echo $i."<br />";
> /* retrieve children of parent */
> $get = "SELECT DISTINCT `". $tierArray[$i] ."` FROM `POSITION_SETUP` ";
> $get .= "WHERE `COMPANY_ID` = '3' ";
> if($i > 0) {
> $get .= "AND `" . $tierArray[$i - 1] . "` = '" . $child . "' ";
> }
> echo $get."<br />";
> if(!($result = mysql_query($get, $dbc))) {
> echo mysql_errno() . "\t" . mysql_error() . "\n";
> exit();
> }
>
> while($row = mysql_fetch_array($result)) {
>
> /* indent and display the title of this child */
> echo str_repeat(' ',$i).$row[$tierArray[$i]]."<br />\n";
>
> /* get the children's children */
> display_children($i + 1, $row[$tierArray[$i]]);
> }
> }
>
> It does produce the right query for only the first child in each case, I
> cannot get it to go deeper. I have just been looking at it for too long.
> TVMIA!
Forgot to say that if I isolate any one level without recursion I get all of
the results for that level.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php