Glad to see I'm not the only one hard at it today ;)
Anyway, with a few minor tweaks and your helpfully suggestion below, I got it working perfectly now.... thanks abunch, much appreciated.
Cheers ;-)
-- Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rob Dixon wrote:
Mike Blezien
a happy new year... but some of us have to work on the holiday ;)
Got a code here that I need to generate an array so it can be used further down in the script. Here is the code snip ########### START OF CODE ################################# my @membership = $cgi->param('membership'); my $ct = ($#membership + 1); my $x = 1; my $totalct = ($ct+1);
unless($ct) { $apex->error("ERROR MESSAGE HERE"); }
my $col_arrayref = $apex->get_column_names("site_subscriptions"); my @savedata = (); my($sfield,$svalue,$description,$newline);
while ($x < $totalct) {
for (my $i; $i<@{$col_arrayref}; $i++) { next if $col_arrayref->[$i] eq 'signupid'; $sfield = $x.$col_arrayref->[$i]; $svalue = $cgi->param("$sfield"); $description = $x."description"; chomp $svalue;
unless($sfield eq $description) { unless($svalue) { $apex->error("$sfield is a required field"); } }
push(@savedata,$svalue); } $x++; }
print $cgi->header(); for my $data (@savedata) { chomp $data; print qq~$data<br>~; } exit(); #################### END OF SNIP ######################## # THESE ARE THE RESULTS 10 15.00 0.00 1 10 Days for $15 30 25.00 14.99 2 30 Days for $25
What I am trying to do, is create the @savedata array so the $data is stored like this so, each row a single line: 10 15.00 0.00 1 10 Days for $15 30 25.00 14.99 2 30 Days for $25
Hi Mike.
You're putting a <br> at the end of each field instead of after each membership. Try the code below.
HTH,
Rob
my @membership = $cgi->param('membership');
unless(@membership) { $apex->error('ERROR MESSAGE HERE'); }
my $col_arrayref = $apex->get_column_names('site_subscriptions');
print $cgi->header();
for (my $x = 1; $x <= @membership; $x++) {
my @data;
for (my $i = 0; $i < @{$col_arrayref}; $i++) {
my $colname = $col_arrayref->[$i];
next if $colname eq 'signupid';
my $svalue = $cgi->param($x.$colname)
unless($svalue) { $apex->error("$sfield is a required field") unless $colname eq 'description'; }
push @data, $svalue; }
print qq/@savedata<br>/; }
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>