i have one. it works but you could tweak it up a bit and try to optimize it and make it suit your needs. hope this helps
// function to recurse all subcategories, each record is pipe-delimited, stored and returned in an array
function myRenderCategories($db, $curr_id = '', $count = 0) {
static $options;
if (!isset($curr_id)) $curr_id = '';
$count++;
$strQ = "";
$strQ = "SELECT Autokey, CatLevel, CatCode, Description, IsList FROM Categories";
$strQ .= " WHERE ParentCode = '$curr_id' ORDER BY ParentCode, Categories.SortOrder";
$result = mySelectDB($strQ, $db);
$rows = mysql_num_rows($result);
if ($rows > 0) {
while (list($key, $level, $id, $name, $isList) = mysql_fetch_row($result)) {
$indent = 0;
if ($curr_id != '') {
for ($i = 2; $i <= $count; $i++) {
$indent++;
}
}
$name = "$indent|$name|$level|$id|$key|$isList";
$options[] = $name;
myRenderCategories($db, $id, $count);
}
}
return $options;
}
$arrCategories = myRenderCategories($db, '');