RE: [PHP] Re: Need row number from database select
| From: | SP | Date: | Mon, 15 Apr 2002 01:27:50 +0000 |
| Subject: | RE: [PHP] Re: Need row number from database select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92950@lists.php.net to get a copy of this message | ||
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." ");
}
}