Received: from all.all.ee (puu.all.ee [194.204.49.113]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eA98h8s13052 for ; Thu, 9 Nov 2000 03:43:08 -0500 (EST) (envelope-from alligator@all.ee) Received: from localhost (localhost [127.0.0.1]) by all.all.ee (8.9.3/8.9.3) with ESMTP id KAA11309; Thu, 9 Nov 2000 10:41:54 +0200 Date: Thu, 9 Nov 2000 10:41:54 +0200 (EET) From: Antti Linno To: Astrid Hexsel cc: pgsql-sql@postgresql.org Subject: Re: insert value of form - checkboxes In-Reply-To: <3a0a5ada.2ef3.0@postoffice.csu.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200011/67 X-Sequence-Number: 98 On Thu, 9 Nov 2000, Astrid Hexsel wrote: > Hello all, > > I have a form which has got checkboxes and I am having problems to have their > values stored in different rows of a table. > > > What I have done is: > > # colour_id is the name of my checkboxes in the input tag > > > etc ... > > # I put all the values into the array and split them > > $colour = $formdata{'colour_id'}; > @colours = split (/,/, $colour); Try to print the array out, to check whether all values are there. > > #then I want to insert then into a table (called cart)in the row called colour_id. > If I have more than one value they have to be in different rows. > > # my code: > > foreach $colour(@colours) > { > $qry = INSERT INTO cart VALUES > ('$session_id', '$range_id', '$colour') > } > Try to specify what are you inserting, and use double quotes: foreach $colour (@colours) { $qry = qq{ INSERT INTO cart (session_id,range_id,colour) VALUES ('$session_id','$range_id','$colour') }; $dbh->do(qq{ $qry });# how about this? } Btw, try print out in the loop to see, if you are getting right inserts. > And what happens is that I am only getting just > one value now inserted in the row. If for example I checked 3 boxes I will get > only the last > one. > > The foreach loop works fine out of the query. > > Thanks a lot for any help. Advice, don't take my CGI as pure gold. I use Embperl, and so my cgi may be not so error-free :) Greetings, Antti