Im trying to list a record once and then count how many records. But I keep getting a 
list of all the records and it counts those?? I read in a file with a list of rooms 
and then look for each one that matches dept 22 and Im trying to show it once and then 
count how many for the building?


#!/usr/bin/perl
use strict;
use DBI;
use warnings;
 
my $list = "/etc/cron.d/room.txt";
my $dbh = DBI->connect("dbi:mysql:dept","user","")
        or die("Couldn't connect");
my( $date, $build, $room, $dept );
my $cnt = 1;
open (LIST, "$list") or die "read error";
 
while (<LIST>) {
chomp;
print "For $_ :\n";
my $sql = "select date,build,room,dept from Jun04 where room = '$_' and dept = '22' 
order by date";
my $sth = $dbh->prepare( $sql );
$sth->execute();
my( $date, $build, $room, $dept  );
$sth->bind_columns( undef, \$date, \$build, \$room, \$dept );
 
 
while( $sth->fetch() ) {
print "For $room :\n";
print $cnt++;print "BLD:$build\n";
}
$sth->finish();
 }
 
$dbh->disconnect();


goal output:
For 30 :
10BLD:211
For 20 :
2BLD:1544


Current output:
For 30 :
1BLD:211
2BLD:211
3:BLD211
.
.
10BLD:211
For 20 :
11BLD:1544
12BLD:1544

Thanks For your help
Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to