okay I sorted it now, Code is messey at the moment and will clean it up later, code as follows: function rebuild_links2($x = 0, $a, $tmp) { $mysql = new MySql(); $result = $mysql->query("SELECT * FROM menu_tree WHERE template='".$tmp."' AND parent_id= '".$x."' ORDER BY homep...