"B. Fongo" wrote: > I'm quit confused with what I have below. > > I have 2 database tables; Games and groups. > > Name Group > ############# > John , GroupA > Miler, GroupA > Peter, GroupB > Mathew, GroupB > Mark, GroupB > Luke, GroupA > > I'm trying to select the members based on their groups and insert them > into a different table. > I've written my script to receive the names of the group from param()
Whoa down, Sally!! Where'd the CGI stuff come from? So far, you have told us only about databases. What is the web side of the story? > > and do the job for me, but something is wrong somewhere that makes the > script fail. It inserts members of only one group even if param contains > two group. I've modified the script several times, but still not getting > the desired result. > Assuming the using selected 3 groups and sends them to the script, it > should insert members of all the 3 groups into the games table. > ################################################ > #!/usr/bin/perl -w > > use CGI; > my $obj = new CGI; OK. It is pretty safe to assume that obj is shoirt for object. That still leaves you with the problem that there are infifinite number of objects and object classes in our universe. Your choice of identifier here does nothing to narrow the possibilities. Since you are creating a CGI object, how about: my $cgi_object = new CGI; > > > use vars qw(@groups $group); > > @groups = $obj->param('groups'); What kind of widget does the HTML form ofer for user entry of 'groups'? You should check the CGI docs carefully to ensure that you are correctly receiving this param. > > > do_db(); > > ############ Subroutine############## > sub do_db { > > > foreach (@groups){ > > $sth = $dbh->prepare(qq{SELECT Name FROM Groups WHERE Group = > "$_"}); > $sth->execute(); > } > while (my @value = $sth->fetchrow_array){ > foreach $member (@value){ > $dbh->do(qq{INSERT DELAYED INTO Games(Name) > VALUES("$member") || print_error("$DBI::err","$DBI::errstr) > && die; > } > } > > } > > Your help will be appreciated. Please repost with the relevant background [ie what you are sending from the web-based form]. Then we can get started. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]