# store subparent for each parent my %parent_hash = ( 'Father' => 'Mother', 'Mother' => 'Father' ); if ( @volunteer_date ){ if (exists $parent_hash{$parent}) { my $sub_parent = $parent_hash{$parent}; for $col ( $parent, $sub_parent ) { $sql = "select $col from Roster where User=?"; $sth = $dbh->selectcol_arrayref( $sql, undef, $user ); print $query->h1({-align=>'center'},"$sub_parent, $parent, $user"); if ( @$sth && $sth->[0] ) { # any rows returned? $name = $sth->[0]; # take first one #last; } } } print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name"); foreach $date ( @volunteer_date ) { $sql = "select distinct Volunteer from Volunteer where Volunteer =? and Date =?"; my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date ); #Verify the parent is not signed up. if( @$sth ) { print $query->h1({-align=>'center'}, "You are already signed up for this date: $date"); last; } } } print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name"); foreach $date ( @volunteer_date ) { $sql = "select distinct Volunteer from Volunteer where Volunteer =? and Date =?"; my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date ); #Verify the parent is not signed up. if( @$sth ) { print $query->h1({-align=>'center'}, "You are already signed up for this date: $date"); last; } #end if statement #process the information and update the schedule. else{ my $sql = "select max(Number) from Volunteer where Date =? and Volunteer = 'TBD'"; my $number = $dbh->selectcol_arrayref($sql, undef, $date); $sql = "update Volunteer set Volunteer = '$name' WHERE Date = '$date' and Number = $number->[0]"; $sth = $dbh->prepare($sql) || die "prepare: $$sql: $DBI::errstr"; $sth->execute || die "execute: $sql->[0]: $DBI::errstr"; print $query->h1({-align=>'center'}, "You signed up for this date $date"); $sth->finish (); $dbh->disconnect (); } #end else statement } #end foreach loop } #end if volunteer_date check else{ print $query->h1({-align=>'center'}, "You did not select a date"); } #end else volunteer_date check # print $query->end_html; print $query->h2({-align=>'center'}, $query->a({href=>'../UnSignup.pl'}, 'UNDO SIGNUP'), ' ', $query->a({href=>'../BobSchedule.pl'}, 'BOBS SCHEDULE'), ' ',); $query->end_html; print $query->h3({-align=>'center'}, $query->a({href=>'Volunteer.pl'}, 'BACK'), ' ',); $query->end_html;