Hi everyone, am trying to display report based on quarter ie Quarter1,Quarter2 etc. However,after keying in record for Quarter2, the report below does not display Quarter2 record but still Quarter1 record. Please advise how to make the report display Quarter2 record if the current month is Jun etc. Thanks a lot.
<?php
session_start();
$_SESSION['userid']; // it will print the userid value
require_once("tcpdf_6_2_11/tcpdf/tcpdf.php");
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, "A4", true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('SD');
$pdf->SetTitle('UOP');
$pdf->SetSubject('PDF');
$pdf->SetKeywords('PDF');
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 10, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// Set some content to print
//'<table border="1">';
$tbl_header = '<table border="1"><thead><tr><th>KRA</th><th>KPI</th><th>Measures</th> <th>Last Reported</th><th>Latest Actual</th></tr></thead>';
$tbl_footer = '</table>';
$tbl ='report';
$con=mysqli_connect("localhost","user","","pq");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"select * FROM report where userid='".$_SESSION['userid']."'");
while($row = mysqli_fetch_array($result))
{
If($row['Quarter1']==1) {
$kra = $row['kra'];
$kpi = $row['kpi'];
$measure = $row['measure'];
$progress1 = $row['progress1'];
$nprogress1 = $row['nprogress1'];
$tbl .= '<tr><td>' . $kra . '</td><td>' . $kpi . '</td><td>' . $measure . '</td><td>' . $progress1 . '</td><td>' . $nprogress1 . '</td></tr>';
}
Else If($row['Quarter2']==2) {
$kra = $row['kra'];
$kpi = $row['kpi'];
$measure = $row['measure'];
$progress1 = $row['progress1'];
$nprogress2 = $row['nprogress2'];
$tbl .= '<tr><td>' . $kra . '</td><td>' . $kpi . '</td><td>' . $measure . '</td><td>' . $progress1 . '</td><td>' . $nprogress2 . '</td></tr>';
}
}
// Print text using writeHTMLCell()
$pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');
// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('', 'I');
//============================================================+
// END OF FILE
//============================================================+
?>