Hi i have the below table datas
id parent_id name
1 Machine
2 3 Ram
3 4 Cpu
4 Computer
5 6 food1
6 food2
My need is to select possible parents
for example
1) if we select 'machine' all others can parents
2) if we select 'cpu' then 'ram' and 'cpu' should not be there
3) if we take 'food2' then 'food2', 'food1' should not be there all other have possibility .
How i write a (php,mysql recursive) function in a class . Note :- Only use single function Pls help me Thanks in advance .