Hi everyone,
I'm having a problem on passing values from my combo box. Let me show you first my code. I have 2 files test.php and view.php.
This is what's inside the test.php
while($row = mysql_fetch_array($strSQL)){
$data .= "<tr>";
$data .= "<td>";
$data .= "<input type='checkbox' class='memberchk' name='membersID[]' value='".$row['member_id']."' />";
$data .= "</td>";
$data .="<td>";
$data .= "".$row['name'];
$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>";
}
This is my view.php
$member_id = $_POST['membersID'];
$access = $_POST['access'];
$size = sizeof($member_id);
for($i=0;$i<$size;$i++){
echo "Member id: ".$member_id[$i]."</br>";
echo "Access: ".$access[$i];
echo "</br>";
}
In this code is just a display on every values of my $access and $member_id array variables
These are the values in my database
member_id | names |access|
---------------------------------------------------
1 |Jim | member |
2 |Elson | admin |
3 |Jezel | member |
4 |Rose | admin |
----------------------------------------------
As you can see on the codes above, it has a checkbox and a combo box, and everytime I click on the button update, it will display values on what's inside the $access and $member_id array variables.
My problem here is that every time I change Jezel as an admin, the $access = $_POST will still display member,
But if I try to change Jim as an admin, $access = $_POST will display admin, there will be no problem..
There's also another problem, I need to checked all the checkboxes on the list, so that Jezel's access will changed.
What's the problem with this?
By the way, $access and $member_id is an array.
I was really having a hard time explaining this problem. Just ask me if there's something unclear to you regarding on my explanation. Thanks!
jimgym1989
Forum Newbie
Posts: 6
Joined: Thu May 14, 2009 9:31 am