Sean
----- Original Message ----- From: "Lewick, Taylor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 19, 2004 2:51 PM
Subject: question about doing it right in CGI
Hi all, I have been using perl for sometime for CGI scripts, but have always used the print content-type:html version of doing things.
I would like to learn a better way with the CGI module, but when I read the docs I find it pretty easy to get confused as to whether I should use the object oriented method, or the functional method.
Also, because my script is a cgi form that gets some of the select fields from a mysql database, I am not sure how to convert that over. I don't know how I would make the select field work the same.
I am not asking for someone to rewrite my project, merely provide me with some examples of how they would write the same code using the cgi module so I can figure this out a bit better...
On my form, I am querying a database for a list of names and loading them into a select box. But I found out people want to enter more than one name at a time, so I loop through 15 times, and they can select up to 15 names... They select a name, but I store the name's id, so it acts as a lookup field...
Here is how I do this now..
#Connect to database
print "<table>\n";
for (1..15) {
print "<td nowrap>\n";
$query_teams=("select id, name from teams");
$sth = $dbh->prepare($query_teams);
$sth->execute();
$sth->bind_columns(\$id, \$name);
print "<select name='away_team$_'>"; #$_ traps which pass of the loop
we are in i.e., 3rd pass, 4th pass, etc
print "<option value='0'></option>\n";
while($sth->fetch()) {
print "<option value='$id'>$name</option>\n";
}
print "</select>\n";
$sth->finish();
print "</td>\n";
} #end for loop
print "</table>\n";
#disconnect from databaseHow would I start to convert this with the CGI module. My problems thus far are on a popup menu, how do I specify the field variable that I grab is the ID, while the displayed value is another, and how can I say the first value should be 0, in case they do not enter anything?
Thanks in advance, Taylor
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
