Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!C:\xampp\perl\bin\perl.exe
- use DBI;
- use CGI qw/:standard/;
- my $username = "root";
- my $password = "";
- my $dsn = "dbi:mysql:e-Shop";
- my $dbh = DBI->connect($dsn,$username,$password)
- or die "Cannot connect to database: $DBI::errstr";
- my $sth = $dbh->prepare("SELECT * FROM invoice");
- $sth->execute()
- or die "Cannot execute sth: $DBI::errstr";
- print header;
- print start_html("Printed databases");
- print table({-border=>1}); #Create HTML-Table
- print Tr; #Add a row
- print th(['Employee Number','Name', 'Total','Date']); # Display Table Header (1st row)
- while (@row = $sth->fetchrow_array()) {
- $Username=$row[0]; #read first field from table
- $EMPLOYEE=$row[1]; #read second field from table
- $Total=$row[2]; #read third field from table
- $DATE=$row[3]; #read fourth field from table
- print Tr; #add new row to HTML_Table
- print td(["$Username","$EMPLOYEE","$Total","$DATE"]); #Display records in the Table Columns
- }
- print end_html;
- $dbh->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement