#!/usr/bin/perl use DBI ; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my($username)= "someuser"; my($password)= "knownuser"; my($dbh)= DBI->connect ("DBI:mysql:hf", $username , $password); my($empName)= param("empName"); my($year) = param("year"); my($mon) = param("mon"); DBI -> trace(4 , 'dbitrace'); # logic my $result; if ($year && $mon){ $result = getResult($empName); } else{ $result = "Select year and month.
"; } # result print < Job Status Display Page $result Back end_of_html #process sub getResult { my $empName = shift; my $table = q!!; my $date1 = $year.$mon.'00'; my $date2 = $year.($mon++).'00'; my $sql = "select * from jobStat where cdate > ? and cdate < ?"; my $noMsg = "No records found for given date.
"; if ($empName){ $sql .= " and empName='$empName'"; $noMsg = "No records found for $empName for given date.
"; } my $sth = $dbh->prepare($sql); $sth->execute($date1,$date2); my $count=0; while (my @arr = $sth->fetchrow_array){ $table .= qq!!; ++$count; } if ($count==0){ return $noMsg; } else { $table .= q!
Current Date Name Job Allocated Allocation Date Target Date Job Under Execution Job Pending Remark
$arr[5] $arr[8] $arr[1] $arr[6] $arr[7] $arr[2] $arr[3] $arr[4]
!; return $table; } }