G
Gary
I have a simple cgi in perl that basically dumpls a file to the screen from
an SQL database and every field can be chaged. Once I have written the rows
to the screen, and the user has changed potentially several rows, what is
the easiest way to update the database with the new entries ?
Basically existing Perl program looks like this.
# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);
# prepare and execute query
$query = "SELECT * FROM WGTextDescription";
$sth = $dbh->prepare($query);
$sth->execute();
# assign fields to variables
$sth->bind_columns(\$QId, \$QSId, \$Description);
$V1=1;
while($sth->fetch()) {
print "<tr><td><input type=hidden name=A$V1 value=$QId>$QId<td><input
type=hidden name=B$V1 value=QSId>$QSId<td><input type=textbox
value=$Description name=D$V1>\n";
$V1=$V1+1;
}
QId and QSId are keys on the file which do not need to be displayed, but
$Description can be changed and needs to be stored after alteration.
The crude way would be as I have done which is to assign each field output
to the screen a code (A$V1) which later I can loop through and use to update
the relevant database rows, BUT there must be a cleaner method -
Any help appreciated.
20+ years programming experience but not in Perl.
Thanks
Gary
an SQL database and every field can be chaged. Once I have written the rows
to the screen, and the user has changed potentially several rows, what is
the easiest way to update the database with the new entries ?
Basically existing Perl program looks like this.
# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);
# prepare and execute query
$query = "SELECT * FROM WGTextDescription";
$sth = $dbh->prepare($query);
$sth->execute();
# assign fields to variables
$sth->bind_columns(\$QId, \$QSId, \$Description);
$V1=1;
while($sth->fetch()) {
print "<tr><td><input type=hidden name=A$V1 value=$QId>$QId<td><input
type=hidden name=B$V1 value=QSId>$QSId<td><input type=textbox
value=$Description name=D$V1>\n";
$V1=$V1+1;
}
QId and QSId are keys on the file which do not need to be displayed, but
$Description can be changed and needs to be stored after alteration.
The crude way would be as I have done which is to assign each field output
to the screen a code (A$V1) which later I can loop through and use to update
the relevant database rows, BUT there must be a cleaner method -
Any help appreciated.
20+ years programming experience but not in Perl.
Thanks
Gary