[ic] possible to update multiple records with a single form

Peter peter at pajamian.dhs.org
Thu Jan 22 04:33:51 UTC 2009


On 01/21/2009 04:03 PM, DB wrote:
> Sorry - my original post had a typo which is fixed here
> 
> I added a field named 'notes' to my orderline table. I want to create a
> form which list the code and notes fields for each orderline record with
> a given order_number, which I can easily to with a mysql query.
> 
> But, I want the notes field to be editable for each record and then have
> all records updated when I submit the form.
> 
> Does anyone have any experience or advice?

It's a fairly simple matter.  You just have to generate unique form
field names (textarea) on the initial db query and then run through them
and populate the from the mv_click routine or the success page.  For
example, say the db column name is "notes" and the table is "orderline"
you could do something like this inside the list (for the query):

<textarea name="notes-[sql-code]">[sql-param notes]</textarea>

...Then inside the mv_click, do something like:

[perl orderline]
my $db = $Db{orderline};

while (my ($key, $value) = each %$Values) {
	next unless $key =~ s/^notes-//;

	$db->set_field($key, 'notes', $value);
}

return;
[/perl]



Note that if you have more than a single field to set then it would be
more efficient to use $db->set_slice().  See
http://www.interchange.rtfm.info/icdocs/Interchange_Perl_objects.html#Database_access_methods
for more info.


Peter



More information about the interchange-users mailing list