you are querying recursive mysql !!! it's really bad. Just read the results to array and then make recursive function or while loop on array .
Regards.