The issue you are facing, is that checkboxes only transfer the values when they are checked. For e.g., in the case you have above, your for loop only goes one look where $size takes the value of 1 in view.php but the $access has a array length of 4 and the value you actually need is in the 3rd position.
To make this more clear, in the example you stated above would be you are selecting Jezebel and changing the member access to admin
Member ID array -> member_id[0]=3
Access array -> access[0]=member, access[1]=admin, access[2]=admin, access[3]=admin
when you should actually have had
Member ID array -> member_id[0]=1,member_id[1]=2,member_id[2]=3, member_id[3]=4
Access array -> access[0]=member, access[1]=admin, access[2]=admin, access[3]=admin
When 0 matches 0 index above you will get member as the access type when actually it should have been member_id[2] which should match access[2]. I hope this makes things clear. In order to correct this, you would need to transfer all the checkbox values which unfortunately HTML or PHP does not do on its own, so you need to create a serialization to help it along.
Try the following code.
$i=0;
while($row = mysql_fetch_array($result)){
$data .= "<tr>";
$data .= "<td>";
$data .= "<input type='checkbox' class='memberchk' name='serialID[]' value='$i-{$row['member_id']}' />";
$data .= "</td>";
$data .="<td>";
$data .= "".$row['names'];
$data .="</td>";
$data .="<td>";
$data .= "<select name='access[]'>";
if($row['access'] == 'member'){
$data .="<option selected value='member'>Member</option>";
}
else{
$data .="<option value='member'>Member</option>";
}
if($row['access'] == 'admin'){
$data .="<option selected value='admin'>Admin</option>";
}
else{
$data .="<option value='admin'>Admin</option>";
}
$data .="</select>";
$data .="</td>";
$data .= "</tr>";
$i++;
}
In the above, I have changed the member_id to a serial_id which we will be using in the view.php file. This will help "pad" the checkboxes later. So we would actually be transferring the serial position, as well as the member_id.
In the view.php file we would need
$serial_arr = $_GET['serialID'];
$member_id = array();
foreach($serial_arr as $value){
$serial = explode("-",$value);
$member_id[$serial[0]]=$serial[1];
}
$access = $_GET['access'];
$size = sizeof($access);
for($i=0;$i<$size;$i++){
if ($member_id[$i]!=""){
echo "Member id: ".$member_id[$i]."</br>";
echo "Access: ".$access[$i];
echo "</br>";
}
}
In the above, you will notice that I have added a foreach loop to explode the serial array and create a new member array to take care of PHP just transferring only the checked values. This should make sure the0 matches 0 index for Jim or 2 matches 2 index for Jezebel.
Try it out and let me know if you have any questions. All the best!