Jump to content

Report Printing Help


satheeshpr

Recommended Posts

Hi All,

 

I am trying to generate a PDF report using the below code. the report is being generated perfectly. The problem that I face is that, while printing the report the browser disregards the "IF" condition that I have given in the code.

 

Explanation :

-----------------

It prints all the data in the MySQL database wherein I wanted the data to be printed only on a certain condition. How do I achieve this?

 

 

<?php

mysql_connect('localhost','user','pass');

mysql_select_db('vaccine');

$array = mysql_query("SELECT cattle_n FROM vactbl");

$num_rows = mysql_num_rows($array);

$array = mysql_query("SELECT * FROM vactbl");

$num_rows = mysql_num_rows($array);

while($info = mysql_fetch_array( $array ))

{

$mas_date = $info['masdt'];

$mas_time = strtotime($mas_date);

$two_week = strtotime("+2 week");

$rpt_date = abs($two_week - $mas_time);

if ($rpt_date >= 7776000)

{

require('mysql_table.php');

 

class PDF extends PDF_MySQL_Table

{

function Header()

{

    //Title

    $this->SetFont('Arial','B',40);

    $this->Cell(0,6,'Cattle List',0,1,'C');

    $this->Ln(10);

    //Ensure table header is output

    parent::Header();

}

}

 

//Connect to database

$pdf=new PDF();

$pdf->AddPage();

//First table: put all columns automatically

//$pdf->Table('select * from cattle_det order by no');

//$pdf->AddPage();

//Second table: specify 3 columns

$pdf->AddCol('cattle_n',20,'Cattle','C');

$pdf->AddCol('masdt',40,'Mastitis Date', 'C');

$pdf->AddCol('fmdt',40,'FM Date','C');

$pdf->AddCol('onedt',40,'Vaccine1 Date','C');

$pdf->AddCol('twodt',40,'Vaccine2 Date','C');

$prop=array('HeaderColor'=>array(255,150,100),

            'color1'=>array(210,245,255),

            'color2'=>array(255,255,210),

            'padding'=>2);

$pdf->Table('select cattle_n, masdt, fmdt, onedt, twodt from vactbl order by cattle_n limit 0,10',$prop);

$pdf->Output();

}

else {}

}

 

?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.