Suneth Perera
Suneth Perera

Reputation: 75

opening a pdf report in a new page

The following gives a php script(report.php) that generates a pdf report when a button is clicked! unfortunately the pdf opens on the same page i want to get the pdf opened on a new page! how can i achieve this?

<?php
require_once("includes/db.php"); // provides db connection

require("fpdf/fpdf.php");

}

$sql="SELECT count(Email) as Number, Date from reportorder";
$result=mysqli_query($db,$sql);
$pdf=new PDF();
$pdf->AddPage();
$pdf->AliasNbPages();
$pdf->SetFont('Arial','B',12);

$pdf->Cell(90,10,'Date',1,0,'C',0);
$pdf->Cell(90,10,'Number of orders',1,1,'C',0);


while($row=mysqli_fetch_array($result))
{

  // cell with left and right borders

$pdf->Cell(90,10,$row['Date'],1,0,'C',0); // 1,0 
$pdf->Cell(90,10,$row['Number'] ,1,1,'C',0);


}

$pdf->output();

?>

The button part is in a page which is loaded inside an iframe

<a href='report.php'>

    <input class='button1' type='button' value='View report' >
    </a>

Upvotes: 0

Views: 34

Answers (1)

M A SIDDIQUI
M A SIDDIQUI

Reputation: 2205

<a href='report.php' target="_blank">

need to add this target attribute

Upvotes: 1

Related Questions