Jump to content

ALMOST infinite loop?


ensellitis

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/196306-almost-infinite-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.