lilywong Posted March 22, 2006 Share Posted March 22, 2006 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.================================================================<?phprequire('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();?>================================================================ Quote Link to comment Share on other sites More sharing options...
lilywong Posted March 22, 2006 Author Share Posted March 22, 2006 anyone has got any ideas ? Quote Link to comment Share on other sites More sharing options...
wisewood Posted March 22, 2006 Share Posted March 22, 2006 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?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.