I currently have this function

processfn('sponsor = 1', 1, '', 0, 'buyer = 0');

function processfn($sponsor, $level, $sad, $sadista, $bumili) {



	$result = mysql_query("SELECT id FROM ahentes WHERE $sponsor") 
	or die(mysql_error()); 
	if (mysql_num_rows($result) > 0) { 
	$sad = mysql_num_rows($result);
	while ($row = mysql_fetch_array($result)){
			
			$sila[] = "buyer = '".$row['id']."' ";
			$output[] = "sponsor = '".$row['id']."' ";
	}
	$sponsor = implode(' or ', $output);
	$tsk = implode(' or ', $sila);


	    processfn($sponsor, $level+1, $sad, $sad+$sadista, $tsk);

 

	}

	}

With the code above, I can successfully get all I need except the "$tsk". Well, it is being displayed but my target is get all the id extracted throughout the recursion and make them as 1 variable. Here's a sample result.

Level 1 result : buyer = 1 or buyer = 2 or buyer = 3
Level 2 result : buyer = 4 or buyer = 5 or buyer = 6

My Goal is make it like this: buyer = 1 or buyer = 2 or buyer = 3 or buyer = 4 and so on..

Thanks in advance geeks! ^_^

Recommended Answers

All 3 Replies

If you return $tsk from your function, then you can merge it with the previous one.

Member Avatar for rajarajan2017

echo your $tsk and check whether getting the output.

OK got it. Thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.