2
<?php
require('mysql_report.php');
$checkbox = $_GET['checkbox'];
//geting Array of values from GET methode 
foreach ($checkbox as $value)
  {
    $sql="SELECT name,address,email,problem,reply_query FROM query where id = $value ";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)){

         }
    $pdf = new PDF('L','pt','A4');
    $pdf->SetFont('Arial','',12);
    $pdf->connect('localhost','uname','pwd','mydb');
    $attr = array('titleFontSize'=>18, 'titleText'=>'Report');

    $qry=$pdf->mysql_report($sql,false,$attr);
    }       
$pdf->Output();
?>

here is the code i got the array of values from $_GET['checkbox']; how i got the pdf while the selected check boxes

1 Answer 1

1

You have placed the pdf generation code inside the foreach loop. It should be outside. Try this:

$sql="SELECT name,address,email,problem,type,other,reply_query FROM query where";
$i = 1;
foreach ($checkbox as $value)
{
                    if($i<count($checkbox))
                    {
                    $sql=$sql." id = \"".$value."\" OR";
                    $i++;
                    }
                    else
                    {
                    $sql=$sql." id = \"".$value."\"";
                    }
}       

    $pdf = new PDF('L','pt','A4');

    $pdf->SetFont('Arial','',12);
    $pdf->connect('localhost','root','asdfgh','Tree_help');
    $attr = array('titleFontSize'=>18, 'titleText'=>'Treehealth Report');
    $qry=$pdf->mysql_report($sql,$dump=false,$attr=array());        
    $pdf->Output();

This should give you the correct output :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.