Perl::DBI Friends,
In order to make my life somewhat easier (I think), I am using JavaScript to
fill out an entire form rather than type out all of the array[refs] in the
values field of each form.  I need to get an array of all of the Column
names since they are also identical to the field names (what a coincidence),
however I am getting only two column names returned.

The error I am getting is one where only the "FirstName" Column name is
returned and then the "StudentID" Column name is returned for the rest of
the array, all 50 or so columns.  This is on an Access database, which will
be converted into an SQL 2000 database after this early stage of
development.  Here's the snippet of code I'm currently using to get the
array.  I am only alerting the array for test purposes, to return the value
immediately.

<CODE>
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use DBI;

my $form = new CGI;

if ($form->param("StudentID")){
PrintThePage($form);
}
else{
print "Location: main.html\n\n";
}

#sub Print the Page
sub PrintThePage($form){
my $StudentID = $form->param("StudentID");
#connect to the Database
my $DBH = DBI->connect("DBI:ODBC:Registrar") or die "$!";
my $SQL = qq'SELECT * FROM StudentList WHERE StudentID = $StudentID';
my $STH = $DBH->prepare($SQL) or die $DBH->errstr();
$STH->execute() or die $STH->errstr();

my @StudentInfo;
@StudentInfo = $STH->fetchrow_array();
print $form->header();
print qq'
<html>
<head>
<title>Tyndale Student Enrollment Form</title>
<LINK REL="stylesheet" HREF="enrollment.css">
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">
var StudentInfo = new Array(
';
my $Value;
foreach $Value (@StudentInfo){
print " '".$Value."',\n";
}
print qq'\'\');
var ColNames = new Array(';
foreach $Value (@StudentInfo){
print " '". $STH->{NAME}->[$Value] ."',\n";
}
</CODE>

Thanks for reading this long message,

Randy Peterman
Alt-N Technologies
www.altn.com

Helping the World Communicate.


Reply via email to