Jump to content

fpdf problem


lilywong

Recommended Posts

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();
?>
================================================================
Link to comment
https://forums.phpfreaks.com/topic/5474-fpdf-problem/
Share on other sites

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
?>
Link to comment
https://forums.phpfreaks.com/topic/5474-fpdf-problem/#findComment-19652
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.