1 #!/usr/bin/perl 2 use strict; 3 use Data::Dumper; 4 use CGI; 5 use DBI; 6 use Template; 7 8 $| =1; 9 #print "Content-type: text/html\n\n"; 10 print "Content-type:text/html\r\n\r\n"; 11 print "html"; 12 13 my $driver = "mysql"; 14 my $database = "RON"; 15 my $dsn = "DBI:$driver:database=$database"; 16 my $userid = "root"; 17 my $password = "test"; 18 19 20 21 22 my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr; 23 my $sth=$dbh->prepare("SELECT * FROM INVOICE"); 24 $sth->execute(); 25 26 my $data = $sth->fetchall_hashref('Invoice_Number'); 27 $sth->finish(); 28 $dbh->disconnect(); 29 30 my %trend = %$data; 31 32 print Dumper(%trend); 33 34 foreach (keys %trend){ 35 36 my $invoice_nu = $trend{'Invoice_Number'}; 37 print "hello
\n"; 38 39 40 } 41 foreach (1..10) { 42 print "hello line $_;
"; 43 } 44