Thanks for everyone who helped. I was trying to keep track of the row number from a database select and everyone who said to pass the row number variable through the function was correct. I finally got it to work by passing the variable by reference.
-----Original Message----- From: Kevin Bucknum [mailto:[EMAIL PROTECTED]] Sent: April 15, 2002 10:29 AM To: '[EMAIL PROTECTED]' Subject: RE: [PHP] Re: Need row number from database select Keep track of it outside of the function in a global variable. > -----Original Message----- > From: SP [mailto:[EMAIL PROTECTED]] > Sent: Sunday, April 14, 2002 8:28 PM > To: David Robley; [EMAIL PROTECTED] > Subject: RE: [PHP] Re: Need row number from database select > > > I see what you are trying to do David but that was what I > tried first but it > doesn't work because the function calls itself depending if it's not a > parent so the alternating colors become all messed up depending on the > structure of my folders. That's why I was hoping to get the > number for each > of the result returned so I could change the color depending > if it was odd > or even. > > Any other suggestions? > > > > -----Original Message----- > From: David Robley [mailto:[EMAIL PROTECTED]] > Sent: April 14, 2002 6:50 PM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] Re: Need row number from database select > > > Well, you don't need to know what row number is. Something like: > > function build_folder_tree(&$output, $parent=1, $indent="") > { > $color = "red"; // Set var to first option > > $qid = mysql_query("SELECT id, name FROM folders WHERE parent_id = > $parent"); > while ($cat = mysql_fetch_object($qid)) > { > $output .= $cat->name + $indent; // here is where I want > to assign diff. > colors > $color == "red" ? $color = "blue": $color = "red"; // > Cycle color for > each iteration > > if ($cat->id != $parent) > build_folder_tree($output, $cat->id, $indent." "); > } > } > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php