将mysql数据导出为pdf文件

时间:2012-05-18 06:46:14

标签: mysql export

我想将mysql表导出为pdf格式。请帮帮我

我试过这段代码。这是我的代码

My.php

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("jass12", $con);




$result = mysql_query("SHOW COLUMNS FROM ja");

 $i = 0;

if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) 
{

@$csv_output .='"'.$row['Field'].'","';

$i++;}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ja");

while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].",";

}
$csv_output .= "\n";
}
@$filename = $file."_".date("d-m-Y_H-i",time());

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: xls" . date("Y-m-d") . ".xls");
header( "Content-disposition: filename=".$filename.".xls");

print $csv_output;

exit;
?>

它产生错误&amp;也作为输出提供xls文件。

我想获得将数据库文件转换为pdf的确切编码。

请帮帮我

1 个答案:

答案 0 :(得分:0)

尝试使用FPDF http://www.fpdf.org/