I'm not thinking at 100% right now (not enough sleep), but my first idea is...
Pass a counter to findChildren(). Maybe have it start out as: findChildren($name->id, 0); Where 0 means you're at the top level and would mean no indentation (or whatever you would need).
Then in your findChildren() function, when you call findChildren() again, you could do: findChildren($name->id, $count + 1);
I see you have a $depth variable which looks like you're on the right path. Before executing echo $depth." ".$name->name."<br>", toss in another for() loop to loop the number of times of $count. Maybe something like this:
function findChildren($id, $count) {
global $db;
$names = $db->get_results("SELECT * FROM names WHERE _parent = ".$id."");
if (!count($names) == 0) {
foreach ($names as $name) {
for($a = 0; $a < $count; $a++)
echo '&nbsp;'; // or whatever your indent will be
echo $depth." ".$name->name."<br>";
findChildren($name->id, $count+1);
}
}
else {
}
}
I left $depth in there since I'm not sure what you're plans are for that. I haven't tested the code so I'm not sure of the quality... See if it makes sense.