Need help on Mysql Select to show all under one id using php.

Hi all, need your help, any one can give an example code for what i am trying to do here is, using php and mysql,

Database structure : (Figure A)
Line 1 A —
/ \ \
Line 2 B C D
/ | \ | |
Line 3 E F G H I
/ |
Line 4 J K

Output structure : show out in php ( Figure B)
Line 1 A ————
/ \ \
Line 2 B C D
|…

Need help on Mysql Select to show all under one id using php.