I am having some problems with updating a part of my script.
I have a webpage wher users can mark checkboxes next to each user they want to ‘recycle’ with another use.
I store the users id in an array like this:
$refsid= explode(',',$_POST['referralIds']);
$users->_recycleMulti($membershipData['recycle_price'], $userdata['username'], $refsid);
Then, in my _recycleMulti function, I wish to do the actual recycling. Whether it is just one user that have been selected, or 10. Therefore, I am using a for loop.
Yet it still only just updates one user.
My _recycleMulti function looks like this:
function _recycleMulti($value, $username, $referrals_array){
for($i=0; $i < count($referrals_array); $i++){
mysql_query("do the update here");
}
return "success!";
}
var_dump($_POST['referralIds']); is returning:
string(3) "4,5"
This is correct, as I have checked two checkboxes. The ids match the ones in the database.
var_dump($refsid); is returning:
array(2) { [0]=> string(1) "4" [1]=> string(1) "5" }
What am I doing wrong?
You could change the for loop to a foreach though it should not make a difference in the execution
that might help you see what you’re executing, or if that’s not working well enough, echo your SQL statement and make sure it’s doing what you think it is.