Advertisement
Guest User

Untitled

a guest
Mar 26th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.00 KB | None | 0 0
  1. #!C:\xampp\perl\bin\perl.exe
  2. use DBI;
  3.  
  4. use CGI qw/:standard/;
  5.  
  6. my $username = "root";
  7. my $password = "";
  8. my $dsn = "dbi:mysql:e-Shop";
  9.  
  10. my $dbh = DBI->connect($dsn,$username,$password)
  11.           or die "Cannot connect to database: $DBI::errstr";
  12.  
  13. my $sth = $dbh->prepare("SELECT * FROM invoice");
  14.  
  15. $sth->execute()
  16. or die "Cannot execute sth: $DBI::errstr";
  17.  
  18. print header;
  19.  
  20. print start_html("Printed databases");
  21.  
  22.  
  23.  
  24. print table({-border=>1}); #Create HTML-Table
  25. print Tr; #Add a row
  26. print th(['Employee Number','Name', 'Total','Date']); # Display Table Header (1st row)
  27.  
  28. while (@row = $sth->fetchrow_array()) {
  29.   $Username=$row[0]; #read first field from table
  30.   $EMPLOYEE=$row[1]; #read second field from table
  31.   $Total=$row[2]; #read third field from table
  32.   $DATE=$row[3]; #read fourth field from table
  33.   print Tr; #add new row to HTML_Table
  34.   print td(["$Username","$EMPLOYEE","$Total","$DATE"]); #Display records in the Table Columns
  35.  
  36.  
  37.    
  38. }  
  39.  
  40. print end_html;
  41.  
  42. $dbh->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement