I have this table schema and data, I have no idea how I can update all parentid 7.5 and 1 if there is a new member added in parentid 7, for example, recently added - 10. Then all his parents will get into the tree ( Note: up to 10 parents, only starting parent 7, in order to climb in the tree, you can update the quantity there) 7.5 and 1 will add the quantity up to 500.
CREATE TABLE `mytree` (
`pid` INT(11) NOT NULL,
`memd` INT(11) NOT NULL,
`position` CHAR(1) NOT NULL,
`amount` DECIMAL(10,2) NOT NULL
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
;
pid memd position amount
0 1 1000.00
1 5 L 500.00
1 6 R 0.00
5 7 L 0.00
5 8 R 0.00
7 9 L 0.00
Here is my tree.

After adding a new member 10
pid memd position amount
0 1 1500.00
1 5 L 1000.00
1 6 R 0.00
5 7 L 500.00
5 8 R 0.00
7 9 L 0.00
7 10 R 0.00
EDIT
If the parent does not have a child, and then a new one is added, the parent cannot receive 500, or the update cannot be made in the number of parents.
EDIT last problem
, , . , .., , , , 9 10 , '11 '
pid memd position amount
0 1 1500.00
1 5 L 1000.00
1 6 R 0.00
5 7 L 500.00
5 8 R 0.00
7 9 L 0.00
9 10 L 0.00
10 11 L 0.00
11 12 L 0.00
11 13 R 0.00
.
.