[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Creating and processing forms that access a database
Well, Kyle Cook's suggestion definitely helped with submitting a
simple HTML form and processing it with a MiniVend template.
But I'm still having a heckuva time trying to interpolate form values
into an SQL query. I have a feeling that this is because I haven't
yet figured out MiniVend interpolation.
Here is one attempt:
[perl interpolate=1]
my $id = [value test_select];
my $array = [sql type=array]
SELECT name FROM population
WHERE id = $id[/sql];
my $outputstring = '';
my $i;
foreach $row (@$array) {
my $id = $row->[0];
my $name = $row->[1];
$outputstring .= qq{<option value="$id">$name\n};
}
$outputstring;
[/perl]
This created a query that was just fine, aside from that fact that $id
was assigned the scalar value '[value test_select]'.
I tried to use MiniVend's [arg] tags, but those didn't seem to do
much, either:
[perl interpolate=1]
my $array = [sql type=array]
[arg][value test_select][/arg]
SELECT name FROM population
WHERE id = %s[/sql];
... and so forth ...
but that didn't do the trick, either, since it failed to substitute
anything for the %s.
I know that there must be a way to do this, but it sure isn't obvious
from anything I've read or seen! Any ideas?
Reuven