Darkmatter5 Posted October 6, 2008 Share Posted October 6, 2008 I'm using FPDF for PDF output. Here's example database data: TABLE clients TABLE first_name: john last_name: smith company_name: js, Inc. Here's my PHP report. <?php define('FPDF_FONTPATH','../library/font/'); require('../library/fpdf.php'); include '../library/dbconfig.php'; include '../library/opendb.php'; class PDF extends FPDF { function Footer() { $this->SetY(-15); $this->SetFont('Arial','I',10); $this->Cell(0,10,'Page ' .$this->PageNo(),0,0,'C'); } } $pdf=new FPDF('L','pt','Letter'); $query="SELECT $dbname.jobs.job_number, $dbname.clients.last_name, $dbname.clients.first_name, $dbname.clients.company_name, $dbname.counties.county, $dbname.jobs.job_desc, $dbname.jobs.job_loc, $dbname.subdivisions.subdivision, $dbname.jobs.section, $dbname.jobs.lot_blk, $dbname.jobs.fb_pg, $dbname.jobs.fnd_date, $dbname.jobs.acerage, $dbname.jobs.memo_info, $dbname.employees.first_name, $dbname.employees.last_name, $dbname.jobs.vol_pg, $dbname.jobs.estimate, $dbname.jobs.amount, $dbname.jobs.assign_date, $dbname.jobs.completion_date FROM $dbname.jobs LEFT JOIN $dbname.clients ON $dbname.clients.client_id=$dbname.jobs.client_id LEFT JOIN $dbname.subdivisions ON $dbname.subdivisions.subdivision_id=$dbname.jobs.subdivision_id LEFT JOIN $dbname.counties ON $dbname.counties.county_id=$dbname.jobs.county_id LEFT JOIN $dbname.employees ON $dbname.employees.employee_id=$dbname.jobs.employee_id WHERE $dbname.jobs.job_id=$_GET[job_id]"; $results=mysql_query($query) or die(mysql_error() .": $query"); //Start the page $pdf->AddPage(); $pdf->AliasNbPages(); $pdf->SetFont('Arial','B',20); $pdf->Cell(735,30,'Job Details',0,1,'L'); $pdf->Cell(0,30,'',0,1,'L'); while($row=mysql_fetch_array($results)) { if(empty($row['company_name'])) { $client_name=$row['last_name']. ", " .$row['first_name']; } else { $client_name=$row['last_name']. ", " .$row['first_name']. " of " .$row['company_name']; } if($row['job_number']==NULL) { $pdf->SetFont('Arial','B',10); $pdf->Cell(65,15,'Job number: ',0,0,'',0); $pdf->Cell(0,15,'',0,1,'L',0); } else { $pdf->SetFont('Arial','B',10); $pdf->Cell(65,15,'Job number: ',0,0,'',0); $pdf->SetFont('Arial','',10); $pdf->Cell(200,15,$row['job_number'],0,0,'L',0); } if($row['client_id']==NULL) { $pdf->SetFont('Arial','B',10); $pdf->Cell(30,15,'Client: ',0,0,'',0); $pdf->Cell(0,15,'',0,1,'L',0); } else { $pdf->SetFont('Arial','B',10); $pdf->Cell(30,15,'Client: ',0,0,'',0); $pdf->SetFont('Arial','',10); $pdf->Cell(0,15,$row['last_name'],0,1,'L',0); } $pdf->Cell(0,30,'',0,1,'L'); if($row['job_desc']==NULL) { $pdf->SetFont('Arial','B',; $pdf->Cell(70,15,'Job Description: ',0,0,'',0); $pdf->Cell(0,15,'',0,1,'L',0); } else { $pdf->SetFont('Arial','B',; $pdf->Cell(70,15,'Job Description: ',0,0,'',0); $pdf->SetFont('Arial','',; $pdf->Cell(0,15,$row['job_desc'],0,1,'L',0); } //$pdf->Cell(0,30,print_r($row),0,0,'L'); } $pdf->SetFont('Arial','',; include '../library/closedb.php'; $pdf->Output(); ?> If I run the file like that it won't output $client_name as anything. It's empty! If I uncomment $pdf->Cell(0,30,print_r($row),0,0,'L');, it'll report that $row['first_name'], $row['last_name'], and $row['company_name'] all have data in them. So why isn't $client_name being created correctly? Link to comment https://forums.phpfreaks.com/topic/127306-help-with-unknown-array-results-and-pdf-output/ Share on other sites More sharing options...
DyslexicDog Posted October 6, 2008 Share Posted October 6, 2008 I don't think this will help you with your issue, but why did you extend the FDPF class and then not use the extended version in your code? Link to comment https://forums.phpfreaks.com/topic/127306-help-with-unknown-array-results-and-pdf-output/#findComment-658536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.