Thanks so much for your help.  This makes a lot of sense to me.

 

Maureen

 

fliptop wrote:

 

if you set up your form so that each record has the same <input> params,


then they should be submitted in order and you can treat each one as an 

array.  for example (untested, and using limited html):

 

Name: <input type="text" name="name">

Address: <input type="text" name="address">

Phone: <input type="text" name="phone">

<input type="hidden" name="id" value="1">

<br>

Name: <input type="text" name="name">

Address: <input type="text" name="address">

Phone: <input type="text" name="phone">

<input type="hidden" name="id" value="2">

 

 

# and in your cgi:

 

my $dbh = put your db handle code here;

my $q = new CGI;

my @ids = $q->param('id');

my @names = $q->param('name');

my @addresses = $q->param('address');

my @phone = $q->param('phone');

my $sth = $dbh->prepare('update table set name=?, address=?, phone=?

                         where id=?');

 

for (my $i = 0; $i < scalar(@ids); $i++) {

  $sth->execute($names[$i], $addresses[$i], $phone[$i], $ids[$i]); }

 

$sth->finish();

$dbh->disconnect;

 

 

of course, you'll need to do some validation to make sure values were 

submitted and are acceptable.  otherwise, scalar(@ids) may not be the 

same as scalar(@addresses) or scalar(@phone) or scalar(@names).  you'll 

probably want to check to make sure each value exists before trying to 

update it.

 

 

Reply via email to