in reply to Putting a long form into a database
If the former, something like
If the table is in name/value pairs, then the code is much simpler:my $col="insert into table mytable ("; my $val="values ("; foreach (param()) { $col.="$_,"; $val.="?,"; push(@arr,param($_)); # Beware! this will break if any variables hav +e multiple values. } $val=~s/,$//; $col=~s/,$//; $statement="$col) $val)"; $sth=$dbh->prepare($statement); $sth->execute(@arr);
my $sth=$dbh->prepare("insert into table mytable (name,value) values ( +?,?)"); foreach (param()) { $sth->execute($_,param($_)); # will only insert the first value if a + variable has multiple values }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: andling form data
by bar10der (Beadle) on Apr 14, 2004 at 14:43 UTC | |
by matija (Priest) on Apr 14, 2004 at 16:26 UTC |