Here's the situation.
I have a database full of directory information, structured like this:
ID PID Name
The ID is a unique ID to that directory, the PID is the ID to that of its parent directory, the name is the name of the directory that gets displayed.
So a few samples would be like this
ID PID Name
0 0 Root
1 0 Directory1
2 0 Directory2
3 1 Directory3
4 3 Directory4
From a hierarchical point of view, it would look like this.
Root
....Directory1
........Directory3
............Directory4
....Directory2
The problem: Now, I am trying to figure out how to write a part of the script where when you delete one directory, every subdirectory also gets removed.
So if I delete Directory1, Directory3 and Directory4 also should be removed from the database.
So if you delete ID1, you can:
Delete entry where ID == 1
Delete entry where PID == 1
This will still still leave the 4th directory though. So obviously I'll need some type of loop statement that will travel up and down the directory system and remove un-needed directories.
Can anyone lend me a hand?
Thanks,
CSevey