#!c:/perl/bin/perl.exe use strict; use DBI; use CGI; my $DB_Host = 'localhost'; my $DB_Name = 'proyecto'; my $DB_User = 'root'; my $DB_Pass = 'xyz123'; { # begin main #-- # Create a new CGI object to process the HTML form. my $cgi = new CGI; #-- # Get the value of the "Patente" field from our HTML input form. my $PatenteToQuery = $cgi->param('Patente'); my $PedimentoToQuery = $cgi->param('Pedimento'); #-- # Get a connection to the database server, aborting on failure. my $dbh = openDBConnection($DB_Host, $DB_Name, $DB_User, $DB_Pass); if ( ! defined $dbh ) { printErrorPage("Could not open a connection to the database!"); exit; } #-- # Define the query, prepare it, execute it then get the results as an array of hash references. my $sql = "SELECT * FROM final WHERE pat = \"" . $PatenteToQuery . "\"" and WHERE ped = \"" . $PedimentoToQuery ."\"; my $sth = $dbh->prepare($sql); $sth->execute(); my $queryResults = $sth->fetchall_arrayref({}); #-- # Print the results as an HTML table. # # Note: the {'Last'} and {'First'} found below refer to column names in the database table. print STDOUT "Content-Type: text/html\n"; print STDOUT "\n"; print STDOUT "
| Patente | IMP/EXP | PEDIMENTO | PED. ORIGINAL | CLAVE PEDIMENTO | FECHA | RFCAAA | CURPAA | PESOB | SUMA | BANCO | ARCHIVO |
|---|---|---|---|---|---|---|---|---|---|---|---|
| " . $queryResults->[$i]->{'pat'} . " | " . $queryResults->[$i]->{'impexp'} . " | " . "" . $queryResults->[$i]->{'ped'} . " | " . $queryResults->[$i]->{'pedorig'} . " | " . $queryResults->[$i]->{'cveped'} . " | " . $queryResults->[$i]->{'fecha'} . " | " . $queryResults->[$i]->{'rfcaaa'} . " | " . $queryResults->[$i]->{'curpaa'} . " | " . $queryResults->[$i]->{'pesob'} . " | " . $queryResults->[$i]->{'suma'} . " | " . $queryResults->[$i]->{'nombrebanco'} . " | " . $queryResults->[$i]->{'archivo'} ."\n"; } print STDOUT " |