ensellitis Posted March 23, 2010 Share Posted March 23, 2010 Here is the code: $set_payee_q = mysql_query("SELECT * FROM members WHERE ID='$ref'"); while($set_payee = mysql_fetch_assoc($set_payee_q)) { // Get referer's ID $id = $set_payee['ID']; // Count rows, see if referer has enough people under him to get payee status $row_count = get_rows("members WHERE parent='$id'"); // If they have more than 3 people refered if($row_count >= 4) { // Give them payee $payee = $set_payee['ID']; } else { // They have less than 4, so give their parent the payee $payee = $set_payee['parent']; } } I need it to keep checking until there is no more parent to check. And if it finds any parent that has more than 3 people under them, it gives them the payee status. I know there has to be an easy way to do this other than nesting a ton of these over and over again... Please tell me it is possible. I am, again, hitting my head on the wall here. Lol Quote Link to comment https://forums.phpfreaks.com/topic/196306-almost-infinite-loop/ Share on other sites More sharing options...
oni-kun Posted March 24, 2010 Share Posted March 24, 2010 What is "get_rows"? Why can you not use mysql_num_rows? You should not put SQL queries within the loop, as you're going to run the same query for every record, keep it out of it. Quote Link to comment https://forums.phpfreaks.com/topic/196306-almost-infinite-loop/#findComment-1030864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.