Jump to content


Photo

fpdf problem


  • Please log in to reply
2 replies to this topic

#1 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 22 March 2006 - 07:05 AM

Anyone know how to arrange the results into two columns ? i tried but i only manage to display the result in one column, thanks.

I want to display the results into pdf file in 2 columns, for example the $sql returns 10 records, i want each column have 5 records. thanks.
================================================================
<?php

require('fpdf.php');
include("config.inc.php");

$start1 = $_GET[s];
$end1 = $_GET[e];

$con3 = " AND card_trans.DateCreate BETWEEN '$start1' AND '$end1'";
$sql = $db->Prepare("SELECT * FROM member_details,card_trans
WHERE member_details.MemberID=card_trans.MemberID
AND card_trans.TransStatus='A' $con3 ");
$rs = $db->Execute($sql);
$total = $rs->RecordCount();

while(!$rs->EOF)
{
$code = $rs->fields["MemberFullName"];

$a= $rs->fields["MemberAddress"];
$b= $rs->fields["MemberPostcode"];
$code2 = $a."\n".$b;

$code3 = $code."\n".$code2;

$column_code = $column_code.$code3."\n\n";
$rs->Movenext();
}

//Create a new PDF file
$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();

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

//Now show the 2 columns
$pdf->SetFont('Courier','',12);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(10);

$pdf->MultiCell(100,5,$column_code,1,C);

$pdf->Output();
?>
================================================================

#2 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 22 March 2006 - 02:06 PM

anyone has got any ideas ?

#3 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 22 March 2006 - 02:15 PM

this is my script for doing what you want... cant remember where i got it from... its a bit rough, but it works.

<?php
$bareQuery = "SELECT * FROM your_table";
$queryall = $bareQuery.$sorted;
$resultall = MYSQL_QUERY($queryall);
$numberall = mysql_Numrows($resultall);

if ($numberall==0) {
echo "No Results Found !";
}
else if ($numberall>0) {
$x=0;
?>
<table>
<?
while ($x<$numberall)
{
if (($x%3)==0) { $row="</tr><tr><td class=report>"; } else { $row="<td>"; }

?>

<? echo $row ?>

<td>

<?=$some_variable?>

</td>

<?
$x++;
} // end while
} // end if numberall > 0
?>
wisewood: proven fact, I am both wise, and wooden.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users