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
> 
> 

Reply via email to