Click to See Complete Forum and Search --> : help! question about using fpdf


ryanbong
December 23rd, 2008, 12:22 AM
im using PHP and MySQL

i have a receipt format to be followed, so the printout must fill the receipt exactly.

but i have a problem

heres the format

customer info

product order1 qty1 unitprice1
product order2 qty2 unitprice2
product order3 qty3 unitprice3
product order4 qty4 unitprice4
product order5 qty5 unitprice5
product order6 qty6 unitprice6
product order7 qty7 unitprice7
product order8 qty8 unitprice8
product order9 qty9 unitprice9


prepared by: total: <------here's my problem (this line must be fixed)

the receipt format can have up to 9 product order, if i input 9 products the printout is exact to the receipt, but if i input below 9 product the line where PREPARED BY: and TOTAL: moves up!


is there anyway that cell can be fixed? so it will be exact on the receipt. im using fpdf 1.53

here's my code

<?php

$invoice_no=$_GET['invoice_no'];

include("conn_db.php");
require('fpdf.php');


$result = mysql_query ("SELECT date, invoice_no, customer, address, business_style, tin, total_sales, tax, total_amount, prepared_by, approved_by, released_by
FROM cash_invoice AS ci
WHERE ci.invoice_no = '$invoice_no'");

while($row = mysql_fetch_array($result))
{
$date = $row["date"];
$invoice_no = $row["invoice_no"];
$customer = $row["customer"];
$address = $row["address"];
$business_style = $row["business_style"];
$tin = $row["tin"];
$total_sales = $row["total_sales"];
$tax = $row["tax"];
$total_amount = $row["total_amount"];
$prepared_by = $row["prepared_by"];
$released_by = $row["released_by"];
$approved_by = $row["approved_by"];
}

$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();


$pdf->SetFont('Times','B',15);
$pdf->Cell(200,25,$invoice_no,0,0,'R');
$pdf->ln(30);
$pdf->Cell(10);
$pdf->Cell(30,20,$customer,0,0,'L');
$pdf->Cell(160,20,$tin,0,0,'R');
$pdf->ln(10);
$pdf->Cell(10);
$pdf->Cell(30,25,$address,0,0,'L');
$pdf->Cell(80,25,$business_style,0,0,'R');
$pdf->Cell(80,25,$date,0,0,'R');
$pdf->ln(5);
$pdf->SetFont('Arial','B',11);

$prod ="SELECT p.description, ip.qty, ip.unit_price, ip.total, ip.invoice_no
FROM invoice_products as ip
LEFT JOIN product as p on p.prod_id = ip.prod_id
LEFT JOIN cash_invoice as ci ON ci.invoice_no = ip.invoice_no
WHERE ip.invoice_no='$invoice_no'";

$result=mysql_query($prod);


while($row=mysql_fetch_array($result))
{


$description=$row["description"];
$qty=$row["qty"];
$unit_price=$row["unit_price"];
$total=$row["total"];

$pdf->ln(4);
$pdf->Cell(20,50,$qty,0,0,'L');
$pdf->Cell(120,50,$description,0,0,'L');
$pdf->Cell(40,50,$unit_price,0,0,'L');
$pdf->Cell(30,50,$total,0,0,'L');

}
$pdf->ln(5);
$pdf->Cell(5,80,$prepared_by,0,0,'L');
$pdf->Cell(80,80,$approved_by,0,0,'R');
$pdf->Cell(35,80,$released_by,0,0,'R');

$pdf->ln(5);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(10);
$pdf->ln(5);
$pdf->Cell(200,50,$total_sales,0,0,'R');
$pdf->ln(5);
$pdf->Cell(200,50,$tax,0,0,'R');
$pdf->ln(5);
$pdf->Cell(200,50,$total_amount,0,0,'R');

$pdf->Output();

?>

thx! hope someone help me

PeejAvery
December 23rd, 2008, 09:03 AM
Why don't you just fill the extra rows with whitespace?

ryanbong
December 23rd, 2008, 08:39 PM
fill with whitespace? how? will i make a condition? help me please'

PeejAvery
December 29th, 2008, 09:08 PM
Why don't you just create a variable that increments by 1 each reading of the database. Then, you know exactly how many rows were printed. Then, just print enough blank rows to equal 9.

ryanbong
January 1st, 2009, 11:51 PM
or can i use a function footer so that that line will be fixed? is that possible? how?