you can suggest me a title after reading
So i have this database
name id1 id2
carl 1154 0
mary 4592 0
jake 5820 4592
john 6495 0
shannon 1047 6495
kalsey 2281 5820
scarlet 4419 2281
i am gonna tell what i want to do as above since my english is not good. Please give me notice if you dont get it.
- Carl's id2 = 0
- mary'S id2 = 0
- jake's id2 != 0 ----> right there i want to find jake's id2 inside id1 sections. (jack id2= 4592 and this is mary's id1). now i want to get mary's id2 again which is 0 which means i can look for next name (if mary's id2 would not equal to 0 i want to continue through loop)
- john's id2 =0
- shannon's id2 = 6495 ----> 6495 is john's id1 and john's id2 = 0 ----> loop ends
- kalsey's id2 = 5820 -----> 5820 gives me jake—--> jake's id2 is not equal 0 agian(its 4592)--->continue to loop—--> 4592 gives me mary ---> marry's id2 = 0 ---> loop ends
- scarlet's id2 = 2281 ----> takes us to kalsey -----> kalsey takes us to jake ----> jake takes us mary ---> loop ends.
How i am gonna write my program? İ tried something like this.
//first while gets id2
while($row = mysqli_fetch_array($command)){
while ($row[id2] != 0){
//get id1
// find id2
}
}
when this program reaches jake it repeat itself to infinity ------> carl , mary, jake, mary, jake, mary, jake, mary, jake, mary, jake, .....