Need help customizing my dropdown menus.
Posted: Sat Oct 29, 2005 8:55 am
First time poster and complete PHP newbie. I've trawled through the first 10 pages of search results but cannot find an answer so I hope I can have better luck here.
I'm developing a php classifieds site and want to make a simple change to my dropdown menus. Currently, the only difference in appearance between all the categories in a dropdown is that the sub-categories are indented.
I'd like to to make the Main categories display in bold.
This is the code which creates my dropdowns:
Any suggestions?
Also, for newcomers to php like myself, may I recommend the 'teach yourself' book PHP with MySQL by nat macbride
I'm developing a php classifieds site and want to make a simple change to my dropdown menus. Currently, the only difference in appearance between all the categories in a dropdown is that the sub-categories are indented.
I'd like to to make the Main categories display in bold.
This is the code which creates my dropdowns:
Code: Select all
<?
//Create the drop down list of categories
// start with an empty $right stack
$right = array();
// now, retrieve all descendants of the $root node
$result = mysql_query( "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 ($row['catid'] == $catid) { echo " selected"; }
print ">";
echo str_repeat(" ",count($right)).$row['catname']. " (" . $row['total'] . ")";
print("</option>");
// add this node to the stack
$right[] = $row['rgt'];
}
?>Also, for newcomers to php like myself, may I recommend the 'teach yourself' book PHP with MySQL by nat macbride