如何在按钮上生成Pdf报告单击? [英] How Can I Generate Pdf Reports On A Button Click ?
本文介绍了如何在按钮上生成Pdf报告单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里的数据显示在我的屏幕上我从我的Mysql数据库中获取
跟随我尝试过的php脚本,但我必须按下按钮点击你能不能告诉我解决方案???在此先感谢
<?php
// PDF使用多个页面
// 文件创建者:CarlosJoséVásquezSáez
// 您可以联系我:carlos@magallaneslibre.com
// 来自PUNTA ARENAS,MAGALLANES
// INOVO GROUP - http ://www.inovo.cl
define(' FPDF_FONTPATH',' font /');
require(' fpdf.php');
// 连接到您的数据库
include( conectmysql.php);
// 创建新的pdf文件
$ pdf = new FPDF();
// 打开文件
$ pdf->打开();
// 禁用自动分页
$ pdf-> ; SetAutoPageBreak(假);
// 添加第一页
$ pdf->添加页面();
// 设置每页的初始y轴位置
< span class =code-sdkkeyword> $ y_axis_initial = 25 ;
// 打印实际页面的列标题
$ pdf-> SetFillColor(232,232,232);
$ pdf-> SetFont(' Arial',' B',12);
$ pdf-> SetY($ y_axis_initial);
$ pdf-> SetX(25);
$ pdf->单元格(30,6,' CODE',1,0 ,' L',1);
$ pdf->单元格(100,6,' NAME',1,0 ,' L',1);
$ pdf->单元格(30,6,' PRICE',1,0 ,' R',1);
$ y_axis = $ y_axis + $ row_height 跨度>;
// 选择要在PDF文件中显示的产品
$ result = mysql_query(' 从产品中选择代码,名称,价格ORDER BY Code', $链接);
// 初始化计数器
$ i = 0 ;
// 设置每页的最大行数
$ max = 25 ;
// 设置行高
$ row_height = 6 ;
while($ row = mysql_fetch_array($ result))
{
// 如果当前行是最后一行,则创建新页面并打印列标题
if ($ i == $ max )
{
$ pdf-> AddPage();
// 打印当前页面的列标题
$ PDF-> SETY($ y_axis_initial);
$ pdf-> SetX(25);
$ pdf->单元格(30,6,' CODE',1,0 ,' L',1);
$ pdf->单元格(100,6,' NAME',1,0 ,' L',1);
$ pdf->单元格(30,6,' PRICE',1,0 ,' R',1);
// 转到下一行
$ y_axis = $ y_axis + $ row_height ;
// 将$ i变量设为0(第一行)
$ i = 0 ;
}
$ code = $ row [' 代码跨度>];
$ price = $ row [' Price 跨度>];
$ name = $ row [' 代码跨度>];
$ pdf-> SetY($ y_axis);
$ pdf-> SetX(25);
$ pdf->单元格(30,6,$ code,1,0,' L',1);
$ pdf->单元格(100,6,$ name,1,0,' L',1);
$ pdf->单元格(30,6,$ price,1,0,' R',1);
// 转到下一行
$ y_axis = $ y_axis + $ row_height ;
$ i = $ i + 1 < /跨度>;
}
mysql_close($ link);
// 创建文件
$ pdf->输出();
?>
解决方案
pdf = new FPDF( );
// 打开文件
PDF->打开();
// 禁用自动分页
PDF-> SetAutoPageBreak(假);
// 添加第一页
Here Data Is Showing On My Screen That'x Fetching From My Mysql Database
following script of php that i tried but i have to do it on button click ... would u lyk to tell me the solution ??? Thanks in advance
<?php
//PDF USING MULTIPLE PAGES
//FILE CREATED BY: Carlos José Vásquez Sáez
//YOU CAN CONTACT ME: carlos@magallaneslibre.com
//FROM PUNTA ARENAS, MAGALLANES
//INOVO GROUP - http://www.inovo.cl
define('FPDF_FONTPATH', 'font/');
require('fpdf.php');
//Connect to your database
include("conectmysql.php");
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
//print column titles for the actual page
$pdf->SetFillColor(232, 232, 232);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'CODE', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'NAME', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'PRICE', 1, 0, 'R', 1);
$y_axis = $y_axis + $row_height;
//Select the Products you want to show in your PDF file
$result=mysql_query('select Code, Name, Price from Products ORDER BY Code', $link);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
//Set Row Height
$row_height = 6;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'CODE', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'NAME', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'PRICE', 1, 0, 'R', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$code = $row['Code'];
$price = $row['Price'];
$name = $row['Code'];
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(30, 6, $code, 1, 0, 'L', 1);
$pdf->Cell(100, 6, $name, 1, 0, 'L', 1);
$pdf->Cell(30, 6, $price, 1, 0, 'R', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close($link);
//Create file
$pdf->Output();
?>
解决方案
pdf=new FPDF(); //Open file
pdf->Open(); //Disable automatic page break
pdf->SetAutoPageBreak(false); //Add first page
这篇关于如何在按钮上生成Pdf报告单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文