Re: Passing a lot of form values
by blazar (Canon) on May 23, 2007 at 14:26 UTC
|
My basic question is there a simple way to pass 1500 form variables from one page to another?
Far from being an expert in these matters, but AIUI a POST does not have any limitation in this sense. What's the problem?
I understand the idea behind "don't reinvent the wheel" But currently I cannot use any modules as "I can't" install them.
Indeed you "can't", but you can, especially if they're pure Perl: otherwise yes, you may have some troubles.
| [reply] |
Re: Passing a lot of form values
by starX (Chaplain) on May 23, 2007 at 14:28 UTC
|
Lots of ways to store data and move it around in Perl. Lists, hashes, hashes of lists, etc all might be appropriate. Can you post some code that shows us how you're presently working with the data? I and others will be much better able to assist you if you do. | [reply] |
Re: Passing a lot of form values
by Trihedralguy (Pilgrim) on May 23, 2007 at 18:51 UTC
|
Here is what I have so far, but it doesn't like it for some reason:
#Get the row count
my $sp = $dbh->prepare("
select ROWNUM
FROM LAWL.HEHE_SECURITY
ORDER BY ROWNUM DESC;
");
$sp->execute();
my $myrowcounter = $sp->fetchrow_array;
my $countrows = 1;
my %incoming = &read_input; # Read information into associated
# array %incoming.
while ($countrows <= $myrowcounter)
{
my $qty[$countrows] = $incoming{'qty$countrows'}; # Fetch the text fro
+m the array.
my $type[$countrows] = $incoming{'type$countrows'}; # Fetch the text f
+rom the array.
my $equip[$countrows] = $incoming{'equip$countrows'}; # Fetch the text
+ from the array.
my $dept[$countrows] = $incoming{'dept$countrows'}; # Fetch the text f
+rom the array.
my $fstore[$countrows] = $incoming{'fstore$countrows'}; # Fetch the te
+xt from the array.
my $dreceived[$countrows] = $incoming{'dreceived$countrows'}; # Fetch
+the text from the array.
my $rstore[$countrows] = $incoming{'rstor$countrowse'}; # Fetch the te
+xt from the array.
my $ringstore[$countrows] = $incoming{'ringstore$countrows'}; # Fetch
+the text from the array.
my $dated[$countrows] = $incoming{'dated$countrows'}; # Fetch the text
+ from the array.
my $comment[$countrows] = $incoming{'comment$countrows'}; # Fetch the
+text from the array.
my $id[$countrows] = $incoming{'id_$countrows'}; # Fetch the text from
+ the array.
my $action[$countrows] = $incoming{'action_$countrows'}; # Fetch the t
+ext from the array.
}
syntax error at massupdate.cgi line 388, near "@qty["
syntax error at massupdate.cgi line 389, near "@type["
syntax error at massupdate.cgi line 390, near "@equip["
massupdate.cgi had compilation errors.
| [reply] [d/l] [select] |
|
|
my $qty[$countrows] = $incoming{'qty$countrows'};
?? did you really mean to do the my within the while? Also I don't see $countrows being incremented. How about declaring the arrays outside of the while loop?
my (@qty, @type,@equip,@dept); #etc.
while ($countrows <= $myrowcounter)
{
$qty[$countrows] = $incoming{'qty$countrows'};
$type[$countrows] = $incoming{'type$countrows'};
$equip[$countrows] = $incoming{'equip$countrows'};
$dept[$countrows] = $incoming{'dept$countrows'};
#etc.
$countrows++;
}
Not sure if there was anything else wrong but that was my 1st thought. Hope that helps.
-- Carmen | [reply] [d/l] [select] |
Re: Passing a lot of form values
by Trihedralguy (Pilgrim) on May 23, 2007 at 14:41 UTC
|
| [reply] [d/l] |
|
|
Okay... first, especially if you're new at anything, comments are your friend. Spell out in detail what you expect to start with, what you expect to end with, and how you expect to get there. You'll help yourself figure it out, and others.
Anyway, am I correct in thinking that this is the collection of data you're needing to move around?
my %incoming = &read_input; # Read information into associated
# array %incoming.
my $qty = $incoming{'qty'}; # Fetch the text from the array.
my $type = $incoming{'type'}; # Fetch the text from the array.
my $equip = $incoming{'equip'}; # Fetch the text from the array.
my $dept = $incoming{'dept'}; # Fetch the text from the array.
my $fstore = $incoming{'fstore'}; # Fetch the text from the array.
my $dreceived = $incoming{'dreceived'}; # Fetch the text from the arra
+y.
my $rstore = $incoming{'rstore'}; # Fetch the text from the array.
my $ringstore = $incoming{'ringstore'}; # Fetch the text from the arra
+y.
my $dated = $incoming{'dated'}; # Fetch the text from the array.
my $comment = $incoming{'comment'}; # Fetch the text from the array.
my $id = $incoming{'id'}; # Fetch the text from the array.
my $action = $incoming{'action'}; # Fetch the text from the array.
If that's the case, you might consider storing the information as a hash...
my %data;
$data{'qty'} = $incoming{'qty'};
$data{'type'} = $incoming{'type'};
# etc...
And then after you've populated your hash, add it to a list...
my @hashes;
push @hashes, $data;
And then you can just access the members of the list sequentially when you need to update the database.
Or am I missing something in your code? | [reply] [d/l] [select] |
|
|
That seems like what I may need to do. I can develop my own "logic" to process this stuff". But I think you've answered my simple question about how I can go about sending and receiving (the possibility of 150 rows of data) my data using form variables. I have a quick quesiton, when you say "And then after you've populated your has, add it to a list". What do you mean by this? Also when the time comes how to I call a row of data. So if I have like 1 2 3, 1 2 3 (qty, number, stock) How do I call row one then row two of the $data?
| [reply] |
|
|
|
|
|
|
| [reply] [d/l] [select] |
|
|
I thought it was a bad practice to have 1500 variables?
| [reply] |
|
|