I have a database where, upon submitting a form, some tables are supposed to be able to recieve multiple rows, depending on the user input. For example:

my $med1="Award Number 1"; my $med2="Award Number 2"; my $med3="Award Number 3"; my %medals=( "$med1"=>"$me1", "$med2"=>"$me2", "$med3"=>"$me3", my $table="table"; my $state="INSERT INTO ".$table." (uid,mid,qty) VALUES (LAST_INSERT_ID +(),?,?)"; foreach (keys%medals){ if($medals{$_}>0){ my $sth=$dbh->prepare($state); $sth->execute ($_ ,$medals{$_}); } }

This comes from a bunch of text inputs put into a hash so as to get the name of an award and how many times the award was given. This worked all well and fine but when I tried to use the same code with a different table name and column names it wouldn't work. I'm trying to insert rows from checkboxes using a simple array, which would input rows depending on which boxes met a certain condition but it is only inserting one line of the array which met the conditions. I have searched high and low for information on using perl/cgi to input information put into an array and have basically come up with nothing that works.

Is there something I'm missing here(or, I should say what is it I'm missig) when it comes to doing this. I'm basically down to sets of checkboxes and need to enter them (as many as are checked) into mysql table rows.If I could get the checked box info to insert I would be good to go.

Also, if it makes any difference at all--this is being done using xampp


In reply to Inserting Select Array Material to MySql by typomaniac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.