#!usr/perl/bin use CGI; use DBI; $cgi_object = new CGI; $n = 0; $error_message = "No Records Found...Please Select Again"; # $search_type_local = $cgi_object->param(search_type); # $employee_first_name_local = $cgi_object->param(employee_first_name); # $department_type_local = $cgi_object->param(department_id); $search_type_local = 0; $employee_first_name_local = "Graham"; $department_type_local = 1; sub create_query_type_0; sub create_query_type_1; sub execute_query_type_0; sub execute_query_type_1; $dbh = DBI->connect("DBI:ODBC:detailsstore", "anonymous", "password") or die "Couldn't connect to database"; if ($search_type_local == 0){ &create_query_type_0; &execute_query_type_0; if ($sth->rows == 0){ print $error_message; } else { while ($sth->rows ne 0 & $n < 25){ @data = $sth->fetchrow_array(); # line 39 $formmated = $data[0] & " " & $data[1] & " " & $data[2] & " " & $data[3]; # line 41 print $cgi_object->textfield('detailsresults', $formmated, 30, 50); $n = $n + 1; } } } else { &create_query_type_1; &execute_query_type_1; if ($sth->rows == 0){ print $error_message; } else { while ($sth->rows ne 0 & $n < 25){ @data = $sth->fetchrow_array(); $formmated = $data[0] & " " & $data[1] & " " & $data[2]; print $cgi_object->textfield('detailsresults', $formmated, 30, 50); $n = $n + 1; } } } $sth->finish; $dbh->disconnect; sub create_query_type_0{ $sth = $dbh->prepare("SELECT employee_table.employee_first_name, employee_table.employee_last_name, employee_table.employee_extension, employee_table.department_id FROM employee_table WHERE (((employee_table.department_id)=?));"); } sub create_query_type_1{ $sth = $dbh->prepare("SELECT employee_table.employee_first_name, employee_table.employee_last_name, employee_table.employee_extension FROM employee_table WHERE (((employee_table.employee_first_name)=?));"); } sub execute_query_type_0{ $sth->execute($employee_first_name_local) or die "Couldn't execute statement"; } sub execute_query_type_1{ $sth->execute($department_type_local) or die "Couldn't execute statement"; }