Reports with FPDF.

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Reports with FPDF.

Postby shehan31 » Fri Dec 10, 2010 7:54 am

Hi all;
I have devolop a php code by looking at some examples on fpdf. What this does is it imports data from a mysql server onto a pdf. Unfortunatley it dosent appear as i wanted. cells are overlapping each other. Does anyone know how to solve this problem? Please refer my attachments.
Syntax: [ Download ] [ Hide ]

$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");

$queryget = mysql_query ("select * from report ORDER BY Transaction_Number DESC LIMIT 5" ) or die (" error with table");*/

$todayDate = date('Y-m-d');
$queryget = mysql_query ("select * from report WHERE Date='".$todayDate."' " ) or die (" error with table");

$number_of_products = mysql_numrows($queryget);

$column_Customername = "";
$column_Transaction = "";
$column_Time = "";
$column_Weight = "";
$column_Price = "";
$column_Date ="";
$total = 0;

 while ( $row = mysql_fetch_assoc ($queryget) ){
$id = $row['id'];
  $Customername = $row ['Customer_name'];
  $Transaction_Number = $row ['Transaction_Number'];
  $Price = $row ['Price'];
  $Weight = $row ['Weight'];
  $date = $row ['Date'];
  $time = $row ['Time'];
  $column_Customername = $column_Customername.$Customername."\n";
  $column_Transaction = $column_Transaction.$Transaction_Number."\n";
  $column_Time = $column_Time.$time."\n";
  $column_Weight = $column_Weight.$Weight."\n";
  $column_Price = $column_Price.$Price."\n";
  $column_Date = $column_Date.$date."\n";
  $total = $total+$Price;
  $total1 = $total1+$Weight;

 $pdf=new FPDF();

class PDF extends FPDF
//Page header
function Header()
    //Arial bold 15
    //Move to the right
    //Line break

//Page footer
function Footer()
    //Position at 1.5 cm from bottom
    //Arial italic 8
    //Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');

//Instanciation of inherited class
$pdf=new PDF();
    $pdf->Cell(0,10,'Printing line number '.$i,0,1);*/


//Fields Name position
$Y_Fields_Name_position = 40;
//Table position, under Fields Name
$Y_Table_Position = 46;

//First create each Field Name
//Gray color filling each Field Name box


//Bold Font for Field Name
//Now show the 3 columns
$pdf->MultiCell(25,6,'Kg '.$total1,1,'R');
$pdf->MultiCell(25,6,'Rs '.$total,1,'R');

$i = 0;
while ($i < $number_of_products)
    $i = $i +1;


please have a look on this
mypdf.jpg (63.37 KiB) Viewed 1813 times
Forum Commoner
Posts: 59
Joined: Sun Aug 29, 2010 5:24 am

Return to Miscellaneous

Who is online

Users browsing this forum: No registered users and 1 guest