Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用mysql中的查询从php输出pdf_Php_Mysql_Pdf_Fpdf - Fatal编程技术网

使用mysql中的查询从php输出pdf

使用mysql中的查询从php输出pdf,php,mysql,pdf,fpdf,Php,Mysql,Pdf,Fpdf,我们正在做一个项目,我们需要一个经过过滤和改进的报告。使用数据库中的查询,我已经完成了它的select product,从select product中选择avgnumberPer,将*计数为numberPer, monthnameorderdate作为orderMonth,从orderdate中提取Day作为joborders中的orderDay 按产品、orderMonth、orderDay分组,其中orderMonth=March,product=Year BookAlias为 jobor

我们正在做一个项目,我们需要一个经过过滤和改进的报告。使用数据库中的查询,我已经完成了它的select product,从select product中选择avgnumberPer,将*计数为numberPer, monthnameorderdate作为orderMonth,从orderdate中提取Day作为joborders中的orderDay 按产品、orderMonth、orderDay分组,其中orderMonth=March,product=Year BookAlias为 joborders组中的averagePerMonth,monthnameorderdate作为orderMonth(按产品,订单月份) 订单月=三月,产品=年鉴

现在我们需要以pdf格式查看该报告,其中所有内容都乱七八糟。在对FPDF模板中以前的代码进行一些编辑之后,下面是我的代码:

<?php
define('FPDF_FONTPATH', 'font/');
require('mysql_table.php');

class PDF extends PDF_MySQL_Table
{
function Header()
{
//Title
$this->SetFont('Arial', '', 18);
$this->Cell(0, 6, 'Job Orders', 0, 1, 'C');
$this->Ln(10);
//Ensure table header is output
parent::Header();
}
}

//Connect to database
include("connect.php");

$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
//First table: put all columns automatically
$pdf->Table('select product,(select avg(numberPer)  from ( select product,count(*) as          numberPer,
monthname(orderdate) as orderMonth, extract(day from orderdate) as orderDay from joborders 
group by product,orderMonth,orderDay having orderMonth = "March" and product = "Year   Book")alias)as 
averagePerMonth ,monthname(orderdate) as orderMonth from joborders group by  product,orderMonth 
having orderMonth = "March" and product = "Year Book"');
$pdf->Output();
?>
现在我想知道它为什么会出错:

FPDF错误:某些数据已输出,无法发送PDF文件

尝试添加以下行:

ob_end_clean();
其中:

$pdf->Table('select product,(select avg(numberPer)  from ( select product,count(*) as           numberPer,
monthname(orderdate) as orderMonth, extract(day from orderdate) as orderDay from joborders 
group by product,orderMonth,orderDay having orderMonth = "March" and product = "Year    Book")alias)as 
averagePerMonth ,monthname(orderdate) as orderMonth from joborders group by  product,orderMonth 
having orderMonth = "March" and product = "Year Book"');
ob_end_clean(); // HERE
$pdf->Output();

请确保mysql_table.php或connect.phpy上没有回音在实例化PDF之前,您无法打印/显示/回音到流中的任何输出。@RobertRozas mysql_table.php和connect.php没有回音。。php包含PDF\u mysql\u table类,connect.php包含mysql连接。顺便说一句,虽然我知道连接非常不流行,但它们可能在这里起作用@我还有一个使用JOIN的查询。这只是一个测试,看看查看pdf报告是否有效。@BrainAmplier18,我很乐意提供帮助;