Note that you should be extremely careful when accepting user data like this; always use Taint mode and launder user input very carefully. See the discussion in Ch 23 of Camel 3rd Ed. 'Detecting and Laundering Tainted Data'.
Secondly, whenever you need to process SQL in a loop like this, consider using the prepare/execute idiom:
my $sth = $dbh->prepare(<<SQL) INSERT INTO needed_details (quantity,item_number) VALUES (?,?) SQL # Error-check here. foreach my $quantity (@quantity) { $sth->execute($quantity,$item_number); # Error check here. }
At the very least, this will save you the need to explicitly quote your data; if you envisage inserting many rows in a given program execute, this will save you the cost of the DBMS re-compiling the query on every pass (for those DBMSs that support query preparing).
In reply to Re: Accept array from Form and put in DB
by slife
in thread Accept array from Form and put in DB
by peppiv
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |