my ($row,$col) = ('a',0); my $total_cols = $table->get_col_count(); $table->map_cell( sub { my $old = shift; $col++; my $new = qq||; $row++ and $col = 0 unless $col % $total_cols; return $new; }); #### use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use DBI; use DBIx::XHTML_Table; print header(), start_form(); my $DBH = DBI->connect( qw(DB CONNECT INFO HERE), {RaiseError => 1, AutoCommit => 1} ); if (param('go')) { my %hash; foreach (param()) { my ($pk,$field) = $_ =~ /_(\d+)=(\w+)/; next unless $pk; $hash{$pk}->{$field} = param($_); } while (my($pk,$row) = each %hash) { $DBH->prepare( 'update set ' . join(',', map {"$_=?"} keys %$row) . ' where id=?' )->execute((values %$row),$pk); } } my $table = DBIx::XHTML_Table->new($DBH) or die 'whoops'; $table->set_pk(); $table->exec_query('select * from '); $table->map_cell(sub { my $datum = shift; my $row = $table->get_current_row(); my $col = $table->get_current_col(); return qq||; }); print $table->output(), submit(-name=>"go"), end_form(), end_html(); $DBH->disconnect(); #### param() = ( '_926=title', '_926=artist', '_926=album', '_926=year', '_926=genre', '_927=title', '_927=artist', '_927=album', '_927=year', '_927=genre', 'Submit Button' ); #### %hash = ( '926' => { 'artist' => 'Rush', 'genre' => 'rock', 'album' => 'Fly By Night', 'title' => 'Making Memories', 'year' => '1975' }, '927' => { 'artist' => 'Rush', 'genre' => 'rock', 'album' => 'Fly By Night', 'title' => 'Anthem', 'year' => '1975' } );