Take all of the fields associated with one database record and give them all the same suffix. You can use a counter to generate suffixes. Add an additional hidden field to hold the number of records on the form. For example (using the data you provided):

<input type="hidden" name="userid_1" value="1"> <input type="text" name="firstname_1" value="Pedro"> - <input type="text" name="lastname_1" value="Montoya"> - <input type="text" name="email_1" value="pedro@motoya.net"> - <input type="text" name="department_1" value="dept 7"> - Admin <input type="checkbox" name="admin_1"> <br> <input type="hidden" name="userid_2" value="2"> <input type="text" name="firstname_2" value="Lisa"> - <input type="text" name="lastname_2" value="Brannigan"> - <input type="text" name="email_2" value="lisa@hotmail.com"> - <input type="text" name="department_2" value="dept 6"> - Admin <input type="checkbox" name="admin_2" checked> <input type="hidden" name="count" value="2">

Process the returned data with something like this.

my $q = new CGI; my $cnt = $q->param("count"); # validate for numeric and value in rang +e for my $sfx (1..$cnt) { my $userid = $q->param("userid_$sfx"); my $first = $q->param("firstname_$sfx"); my $last = $q->param("lastname_$sfx"); my $email = $q->param("email_$sfx"); my $dept = $q->param("department_$sfx"); my $admin = $q->param("admin_$sfx"); # validate all values above and update user record }

Since you're presenting many records to the user at one time, you will probably have to update all of your database records since there won't be any way to determine which were modified. You may be able to detect modifications with some javascript. If so, I would add a second hidden field for each record whose value could be changed by the javascript to indicate that the record needs an update.

--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

In reply to Re: mysql: edit mutliple forms with one submit button by pfaut
in thread mysql: edit mutliple forms with one submit button by Zecho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.