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
Expand|Select|Wrap|Line Numbers
- 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>";
- }
Expand|Select|Wrap|Line Numbers
- $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>";
- }
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['access'] will still display member,
But if I try to change Jim as an admin, $access = $_POST['access'] 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?
I'm also getting an array size of the $access array variable with a value of 4 even if I just put a one value in the $access array variable.
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!