Id | Parent | Name |
---|---|---|
3 | 1 | Countries |
4 | 3 | Belgium |
5 | 3 | Netherlands |
6 | 3 | Germany |
7 | 5 | Business and Economy |
<?php
function gimmeParent($id) {
global $dir;
$res = mysql_query("SELECT parent, name FROM dir WHERE id=$id");
if (mysql_num_rows($res) > 0) {
$dir[] = ($row = mysql_fetch_row($res));
gimmeParent($row['parent']);
}
}
gimmeParent(7);