------_=_NextPart_001_01C4C690.E4768BD8
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi all, I have a simple web form where a user selects an application
from a drop down menu and then enters email or phone number if they want
alerts on that app...
Simple, it goes right into database..
But it has come to my attention that some users want to enter multiple
emails and numbers at once on a form. That way they don't select an
app, enter a name, hit submit and then start over, etc
Ok, so I created a form with up to 15 entries, looks nice, just not sure
how to go about gathering multiple fields and feed them into the
database. My main problem is in the variable naming..
Here is an example using just the application name
use DBI;
use CGI qw(:standard);
#not showing code for db connection and html headers, assume standard
stuff...
print "<table>\n";
#this code loops through and creates 15 selection boxes for a user to
choose the application name...
for (1..15) {
print "<tr><td>\n";
$query_apps=3D("select app_id, app_name from applications");
$sth =3D $dbh->prepare($query_apps);
$sth->execute();
$sth->bind_columns(\$appid, \$appname);
print "<select name=3D'appname$_'>";
while($sth->fetch()) {
print "<option value=3D'$appid'>$appname</option>\n";
}
print "</select>\n";
$sth->finish()
} #end of for loop
print "</table>\n";
I used $_ so each time through it would see the value of the select box
name is appname1, then appname2, etc...
Then the hard part for me is getting multiple variables. I was thinking
I could either keep pushing onto an array the appname
But I cant say push ( [at] array, appname$_) because that isn't a meaningful
variable...
or I could pass to another form or just call a subroutine I was hoping I
could do something like...
sub Get_Items {
for (1..15) {
my ($A) =3D CGI::param("appname$_"));
print "App Name is $A<br>\n";
}
}
but when I try this it never picks up a value for appname$_
Any ideas. Either I need to use the CGI module a better way, or I need
a little help on passing the variable or naming the variable.
Thanks,
Taylor
------_=_NextPart_001_01C4C690.E4768BD8--
