I have the following code:
$referrals = inputFilter($_POST['referralsIds']);
$array =explode(",",$referrals);
foreach($array as $key=>$value):
/
$s=mysql_query("SELECT * FROM users WHERE upline='".$userdata['id']."' AND id='$value'");
$num_rows=mysql_num_rows($s);
if($num_rows==0)
return 2;
// No error found and the update was succesful - Return success!
mysql_query("UPDATE users SET upline='' WHERE id='$value'");
mysql_query("UPDATE users SET rbalance=rbalance-".$sdata['direct_delete_fee'].", direct_referrals=direct_referrals-1 WHERE username='".$userdata['username']."'");
return 100;
endforeach;
The $referrals variable is posting two values (10,11).But when I put it in a foreach loop, it will only run the query with the first value (10). How to do so it run through ALL values submitted?
Thanks.
You have a
return 100inside your for loop. It’s terminating the loop on its first iteration.returnstatements terminate the enclosing function. If you need to return multiple results, consider pushing them onto an array and then returning the array once you’re done.