All pastes #332295 Raw Edit

Mine

public php v1 · immutable
#332295 ·published 2007-01-29 21:57 UTC
rendered paste body
function buildCategoryOptionTree($id, $depth=0, $html=""){		global $mysql;		$thisCategory = $mysql->query("SELECT * FROM `categories` WHERE `id`='$id'");	$data = $thisCategory->fetchArray();		$html .= "<option value=\"".$data['id']."\">";			if($depth > 0)	{					if($depth > 1)			for($i=0;$i<$depth;$i++)				$html .= "&nbsp;&nbsp;";					$html .= "&#9492;&nbsp;";	}		$html .= $data['name']."</option>\n";	$subcategories = $mysql->query("SELECT * FROM `categories` WHERE `parent_id`='$id'");		if($subcategories->numRows > 0)	{		$depth++;				while($row = $subcategories->fetchArray())		{			$html .= buildCategoryOptionTree($row['id'], $depth, $html);		}	}	return $html;}$result = $mysql->query("SELECT * FROM `categories` WHERE `parent_id`='0' ORDER BY `name`");while($row = $result->fetchArray()){													$categoriesHTML .= buildCategoryOptionTree($row['id'], null);}