First time poster and complete PHP newbie.
I an 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:
<?
//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'];
}
?>
Any suggestions?
Also, may I recommend the 'teach yourself' book PHP with MySQL by nat macbride