473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to pass values from my combo box?

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
Expand|Select|Wrap|Line Numbers
  1. while($row = mysql_fetch_array($strSQL)){
  2.                 $data .= "<tr>";
  3.                 $data .= "<td>";
  4.     $data .= "<input type='checkbox' class='memberchk' name='membersID[]' value='".$row['member_id']."' />";
  5.     $data .= "</td>";
  6.         $data .="<td>";
  7.         $data .= "".$row['name'];
  8.         $data .="</td>";
  9.  
  10.         $data .="<td>";
  11.         $data .= "<select name='access[]'>";
  12.  
  13.                 if($row['access'] == 'member'){
  14.             $data .="<option selected value='member'>Member</option>";
  15.         }
  16.         else{
  17.             $data .="<option value='member'>Member</option>";
  18.         }
  19.  
  20.         if($row['access'] == 'admin'){
  21.             $data .="<option selected value='admin'>Admin</option>";
  22.         }
  23.         else{
  24.             $data .="<option value='admin'>Admin</option>";
  25.         }
  26.     $data .="</select>";
  27.         $data .="</td>";
  28.         $data .= "</tr>";
  29. }
This is my view.php
Expand|Select|Wrap|Line Numbers
  1. $member_id = $_POST['membersID'];
  2. $access = $_POST['access'];
  3. $size = sizeof($member_id);
  4.  
  5. for($i=0;$i<$size;$i++){
  6. echo "Member id: ".$member_id[$i]."</br>";
  7. echo "Access: ".$access[$i];
  8. echo "</br>";
  9. }
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['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!
Feb 7 '11 #1
0 1254

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Matthew Lasar | last post by:
I am trying to study php from a book. But the code doesn't seem to work for me. I set up a form, as follows: <html> <head> <title>form</title> </head> <body> <form action="results.php"...
2
by: Ben | last post by:
Hi, When clicking on a button, a new record must be created in an Access table. See my code: <% set objdc = Server.CreateObject("ADODB.Connection")...
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
5
by: codercoder | last post by:
Hello Helpers, I have a question about passing values through multiple C++ functions: Function A calls function B; Function B calls function C; Function C calls function D; D has two values...
3
by: Prashant P | last post by:
help in asp.net to pass values from a page to a frame inside the same page!!! i call values 4m a database on a click of a button , den that values r supposed to be displayed in a frame dats in the...
2
by: Prashant P | last post by:
help in asp.net to pass values from a page to a frame inside the same page -------------------------------------------------------------------------------- help in asp.net to pass values from a...
15
by: J. Peng | last post by:
Hello, I saw this statement in Core Python Programming book, All arguments of function calls are made by reference, meaning that any changes to these parameters within the function affect the...
6
by: =?Utf-8?B?Unlhbg==?= | last post by:
I am trying to pass a value from a texbox in Form1 to a textbox in Form2 using properties in VS2005 but it doesn't work; please help (project is attached). Code for Game Class: using System;...
0
by: Aniket sonmale | last post by:
i need to pass values to a query in my shell script. my file will contain data as below. 3123213 1234133 4423434 4242343 .
2
by: dougancil | last post by:
I have a page with a gridview and I want to pass the value when a user clicks on a hyperlinked field in the grid to another page. Here is the code for the gridview: <asp:GridView ID="GridView1"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.