View Full Version : Dropdown text colors


Mr Miyagi
02-21-2005, 12:22 PM
Hi,
I'm a bit of a beginner and want in a dropdown with multi level categories thats generated in a php script to have the top category name a different color than the rest.

Is this possible eg

Top Category (this red and the other subcategories normal)
**2nd Subcategory level
****3rd Subcategory level
******4th Subcategory level

If you help me I will get Danielsan to clean your car :)

dudepet39
02-21-2005, 05:29 PM
Yes, of course you could have eg.:


Link Category #1
Link
Link
Link
Link Category #2
Link
Link
Link
Link Category #3
Link
Link
Link

You mean like that? :D.

-Brandon

Mr Miyagi
02-23-2005, 08:33 AM
Hi,
how?
The dropdown is generated in this php script. I can get all the text to change colour but not just the top level :confused:

<?
//Create the drop down list of categories
// start with an empty $right stack
$right = array();

// now, retrieve all descendants of the $root node
$result = q( "SELECT catname, catid, total, lft, rgt FROM $cat_tbl ORDER BY lft ASC;");

// display each row
while ( $row = mysql_fetch_array($result) )
{
// only check stack if there is one
if( count($right) > 0 )
{
// check if we should remove a node from the stack
while( count($right) > 0 && $right[count($right)-1] < $row['rgt'] )
{
array_pop($right);
}
}

// display indented node title
print "<option value='" . $row['catid'] . "'";
if (isset($_REQUEST["catid_search"]))
if ($row['catid'] == $_REQUEST["catid_search"]) { echo " selected"; }
print ">";
echo str_repeat(" *",count($right)).$row['catname']. " (" . $row['total'] . ")";
print("</option>");

// add this node to the stack
$right[] = $row['rgt'];
}

?>
</select>