in reply to Re^2: retrieving similar form params
in thread retrieving similar form params

Now show us a code snippet with a populated version of param and a print that generates the sort of data you want to push into the DB. Something like:

use strict; use warnings; my %param = ( fname1 => "Fred", lname1 => 'Bloggs', email1 => 'fred@xyzzy.com', fname2 => "Joe", lname2 => 'Bloggs', email2 => 'joe@plugh.com', fname3 => "Sue", lname3 => 'Brown', phone1 => '555-1234-567', ); my @entries; #generate entries from parameters print join "\n", @entries; __END__

Prints:

Bloggs,Fred,,fred@xyzzy.com Bloggs,Joe,,joe@plugh.com Brown,Sue,555-1234-567,

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^4: retrieving similar form params
by Anonymous Monk on Nov 27, 2005 at 23:43 UTC
    Hi.

    Using your data structure, this is what I aim to do.

    my %param = ( fname1 => "Fred", lname1 => 'Bloggs', email1 => 'fred@xyzzy.com', fname2 => "Joe", lname2 => 'Bloggs', email2 => 'joe@plugh.com', fname3 => "Sue", lname3 => 'Brown', phone1 => '555-1234-567', ); # assuming everything above passes the sanity check my $stored = qq(INSERT INTO addbook (fname, lname, phone, address, ema +il) VALUES(?,?,?,?,?); my $sth = $dbh->prepare($data); $sth->execute($fname#, $lname#, $phone#, $address#, $email#) or die $d +bh->errstr;
    Each row of fields has to be entered into my database like that.

    Thank you. </code>