Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #use strict;
- #use warnings;
- use DBI;
- my @array = (
- [143, 'ri@moo.com.au', 'Richard', 5],
- [167, 'ri@goo.com.au', 'Mitch', 5],
- [173, 'ri@foo.com.au', 'Ross', 5]
- );
- $dbh = DBI->connect('DBI:mysql:helpdesk', 'staff', 'pass'
- ) || die "Could not connect to database: $DBI::errstr";
- for(my $i = 0; $i <= $#array; $i++){
- my $total = 0;
- print "\n---------------\n $array[$i][1] \n--------------\n";
- my $sth = $dbh->prepare('SELECT hours FROM Bills WHERE entry_owner = ' . $array[$i][0] . ' AND date = date(now())')
- or die "Couldn't prepare statement: " . $dbh->errstr;
- $sth->execute
- or die "Couldn't execute SQL statement:" . $dbh->errstr;
- while (my @row = $sth->fetchrow_array) {
- $total += @row;
- print "@row\n";
- }
- print "Total: " . $total;
- }
- $dbh->disconnect();
Add Comment
Please, Sign In to add comment