Re: multiple input boxes



don't name them the same! :)

if you're going through a loop

$name = $i.'_id';
$name = $i_'first_name';
etc

or, a bit more clever $name = 'user['.$i.'][id];
ie <INPUT name="user[1][id]">
<INPUT name="user[1][first_name]">
<INPUT name="user[1][last_name]">
<INPUT name="user[2][id]">

will create a $_POST var that looks like this when submitted

$_POST = array(
user = array(
1 => array(
'id' => 'whatever',
'first_name' => 'whatever',
'last_name' => 'whatever',
),
2 => array(
'id' => 'whatever',
),
),
);


Auddog wrote:
I have a form that I'm creating that queries my database for active users,
puts them in a list and then adds an input box for each line. I'm having
troubles trying to figure out how I would then input the information from
the input box into my table when submitted. Each line lists out the id,
first name, last name from the query, but each input box is named the same.
How would I change the name of each input box?

Hopefully this makes some sense. Thanks for any help that you can provide.

A

.



Relevant Pages

  • Re: Compare the values of two sorted arrays of variable size.
    ... This algorithm does not check for every possible location in each array. ... > contains a double loop where each element of the inner loop is compared ... > Dim lngMaxAIdx ' Upper value of the A list index. ... one of the lists has finished. ...
    (microsoft.public.scripting.vbscript)
  • Re: Reference other array objects from within loop?
    ... simulate trading programs in CL. ... each and every object in the array. ... facing right now is because of the nature of the code within the loop. ... Be careful with circular lists; don't pass them to LENGTH, and make sure to set *print-circle* to t. ...
    (comp.lang.lisp)
  • Re: [opensuse] bash - why doesnt the tldp bash beginners guide for loop example work?
    ... I have run into a bash problem with a simple for loop I don't ... The echo statement showed that $i was receiving the ... I personally like to use array variables in BASH scripting. ... lists to operate on. ...
    (SuSE)
  • Re: arrays in python
    ... However, I want a much larger array like a 100 elements, so I cant ... using a for loop. ... In python they're called 'lists'. ... For multidimensional 'arrays' you just put lists in lists. ...
    (comp.lang.python)
  • Re: wildcard arrays or lists
    ... lists of IP's. ... Is it possible to use wildcards in an array like ... only option to fill the array "by hand" with a loop with every single IP? ...
    (comp.lang.ruby)