2017-03-29 11 views
-1

SQLをPDFにエクスポートするには、このエラーを解決するにはどうすればいいですか?エラーが発生しました。誰かがサンプルコードを私に提供できますかphpでsqlをPDFにエクスポートする方法、エラーが発生しました

<?php 
define('path','fpdf/font/'); 
require('fpdf/fpdf.php'); 
include 'connection.php'; 
$pdf=new FPDF(); 
$pdf->Open(); 
$pdf->SetAutoPageBreak(false); 
$pdf->AddPage(); 
$y_axis_initial = 25; 
$pdf->SetFillColor(232, 232, 232); 
$pdf->SetFont('Arial', 'B', 12); 
$pdf->SetY($y_axis_initial); 
$pdf->SetX(25); 
$pdf->Cell(30,6,'Complaint',1,0,'L',1); 
$pdf->Cell(30,6,'Date',1,0,'L',1); 
$pdf->Cell(30,6,'Text',1,0,'L',1); 
$pdf->Cell(30,6,'Polar words',1,0,'L',1); 
$pdf->Cell(30,6,'Source',1,0,'L',1); 
$pdf->Cell(30,6,'Company id',1,0,'R',1); 
$y_axis = $y_axis + $row_height; 
$fromdate=$_REQUEST['i_name']; 
$todate=$_REQUEST['s_name']; 
$fromdate=$_REQUEST['address']; 
$todate=$_REQUEST['city']; 
$fromdate=$_REQUEST['contact']; 
$result=mysqli_query($con,"SELECT i_name,s_name,address,city,contact FROM s_reg WHERE limit='1'") or die(mysql_error()); 
$i = 0; 
$max = 25; 
$row_height = 6; 
while($row = mysqli_fetch_array($result)) 
{ 
    if ($i == $max) 
    { 
    $pdf->AddPage(); 
    $pdf->SetY($y_axis_initial); 
    $pdf->SetX(25); 
    $pdf->Cell(30,6,'i_name',1,0,'L',1); 
    $pdf->Cell(30,6,'s_name',1,0,'L',1); 
    $pdf->Cell(30,6,'address',1,0,'L',1); 
    $pdf->Cell(30,6,'city',1,0,'L',1); 
    $pdf->Cell(30,6,'contact',1,0,'L',1); 
    $y_axis = $y_axis + $row_height; 
    $i = 0; 
    } 
    $complainant = $row['i_name']; 
    $date = $row['s_name']; 
    $complainttext = $row['address']; 
    $complainttitle = $row['city']; 
    $polarwords = $row['contact']; 
    $pdf->SetY($y_axis); 
    $pdf->SetX(25); 
    $pdf->Cell(30, 6, $i_name, 1, 0, 'L', 1); 
    $pdf->Cell(30, 6, $s_name, 1, 0, 'L', 1); 
    $pdf->Cell(30, 6, $address, 1, 0, 'L', 1); 
    $pdf->Cell(30, 6, $city, 1, 0, 'L', 1); 
    $pdf->Cell(30, 6, $contact, 1, 0, 'L', 1); 
    $y_axis = $y_axis + $row_height; 
    $i = $i + 1; 
} 

$pdf->Output('report.pdf','F'); 

if($pdf->Output('report.pdf','F')) 
{ 
    echo "Report Created Successfyully CLick to view"; 
} 
else 
{ 
    echo "failed to create Report"; 
} 

$pdf->Output(); 
?> 
+0

**エラー**とは何ですか? – RiggsFolly

+0

と[[よくある質問](どのようなトピックについて私に聞くことができますか? http://stackoverflow.com/help/how-to-ask) と[完璧な質問](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) – RiggsFolly

+0

質問の繰り返しを並べ替え、人々が何が起こっているかを見ることができるようにコードをインデントしました。 – Ghoti

答えて

0

エラーの内容を教えてください。私が見ることのできるところは、コードの最後にあります。

$pdf->Output('report.pdf','F'); 

if($pdf->Output('report.pdf','F')) 
{ 
    ... 

出力関数を2回呼び出すことになります。

私があなたの場合は、fpdf documentationに行き、サンプルをゆっくりと作り、あなたが望むものが得られるまでそれらを適応させます。

関連する問題