function options()
{
$sql = "SELECT CONCAT( REPEAT(' ', COUNT(detail.id) - 1), detay.title) AS name, node.id, node.lft
FROM table AS node,
table AS parent,
table_detail AS detail
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND node.id = detail.page_id
GROUP BY node.id
ORDER BY node.lft";