PHP noob on multiple value reference with only one known id
===

I have this mysql table

    id    parent_id
    1      NULL
    2       1
    3       1
    4       2
    5       4
    6       5


and so on, note that this is a structure for mlm construction.

id is non repeatable number for a member and parent_id is their upline.

In this instance, member id 6 having upline with id 5, and member id 4 is the upline to id 5,and member id 2 is the upline to member id 4,all of which makes those people upline of member id 6.

I know i can retrieve the direct upline of member id 6 by getting its parent id, and the only value we have is member id=6, we get its direct upline by getting parent id,and how to get the parent id of the parent id of 6,and parent id of parent id of parent id of 6 and so on in terms of php.

thank you.