简体   繁体   English

在FPDF中显示Mysql的结果

[英]Displaying results from Mysql in FPDF

I am building a PDF document using FPDF, the problem i am having is that when i take data out for the database and try to show it through a loop the results write on top of one another and not below each other. 我正在使用FPDF构建PDF文档,我遇到的问题是,当我从数据库中取出数据并尝试通过循环显示它时,结果会彼此叠加而不是彼此叠加。

I understand why this is happening, because the cells have the same settings, but not sure how to adjust the cells to align one below the other. 我知道为什么会发生这种情况,因为单元格具有相同的设置,但是不确定如何调整单元格以使其在另一个之间对齐。

Here is my code 这是我的代码

    $query = "SELECT * FROM employment_history WHERE username ='$usernam' ORDER BY    employment_history_id ASC"; 
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)){
$job_title =$row['job_title'];
$company_name =$row['company_name'];
$job_description =$row['job_description'];
$from =$row['from'];
$to =$row['to'];

    $pdf->Cell(10,10, $job_title,0, 0, 'L', FALSE);                         
    $pdf->Cell(10,10, $company_name,0, 0, 'L', FALSE);

    }

Try something like this: 尝试这样的事情:

$pdf->Cell(10,10, $job_title,1,1,'C');                         
$pdf->Cell(10,10, $company_name,1,1,'C');

FPDF Cell doc: http://www.fpdf.org/en/doc/cell.htm FPDF单元格文档: http ://www.fpdf.org/en/doc/cell.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM