RE: [PHP] Re: Need row number from database select
| From: | Kevin Bucknum | Date: | Mon, 15 Apr 2002 14:28:49 +0000 |
| Subject: | RE: [PHP] Re: Need row number from database select | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93002@lists.php.net to get a copy of this message | ||
Keep track of it outside of the function in a global variable.
> -----Original Message-----
> From: SP [mailto:internetracer@yifan.net]
> Sent: Sunday, April 14, 2002 8:28 PM
> To: David Robley; php-general@lists.php.net
> 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:robleyd@paradise.net.nz]
> Sent: April 14, 2002 6:50 PM
> To: php-general@lists.php.net
> 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
>
>