[PHP] passing form variables with the same name

2002-12-05 Thread Doug Parker
I'm passing form variables from a script that is meant to display 
information to be updated in a mysql database, and it sends these to a 
script that updates the changed values.  The problem is, I have a number 
of the same field being passed.  For example, I have two fields in an 
html form - Resource and Task, that need to be updated in a specific 
table, let's call it Projects.  However, I need to update every Resource 
and Task in table Projects.   So if there were 5 rows in Projects, the 
script would display the values for Task and Resource for all 5 rows, so 
that would total 10 input boxes.  Obviously, I loop the display of these 
variables in input boxes as to get all 5 rows.  So in order to send the 
variables to the script that will update them, they need to be unique - 
right?  I can't have the input name="Resource"  for each one, so in the 
loop on the form I resolved this by appending a number to each one - 
e.g. input name="Resource1", input name="Task1", input name="Resource2", 
... etc.  So now I have the unique variables I need, the problem is that 
I have no idea how to loop through them in the update script and update 
each one accordingly.   Can someone give me an idea how to do this?  I'd 
love to use an array, but I don't think you can pass an array value from 
a form and have it work on the update script - e.g. input 
name="Resource[0]"...

any help would be greatly appreciated.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passing form variables with the same name

2002-12-05 Thread 1LT John W. Holmes
> I'd love to use an array, but I don't think you can pass an array value
from
> a form and have it work on the update script - e.g. input
> name="Resource[0]"...

Ah, but you can... You can use exactly what you just wrote and have
$_POST['Resource'][0] in your processing script. Loop through that array and
you're good to go. Or, you can name them as name="Resource[]" and let PHP
handle creating the keys (they'll start at zero, anyhow).

Enjoy...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php