Link to home
Start Free TrialLog in
Avatar of peter2001
peter2001

asked on

multi columns with fpdf

Hi

been trying to figure the code below out it uses fpdf from here http://www.fpdf.org/
to convert a php page to pdf


at the minute it gets the results from the database and puts it into two columns like this below

info 1            info 7
info 2            info 8
info 3            info 9
info 4            info 10
info 5            info 11
info 6            info 12
                      info 13
                      info 14
                      info 15

how would i get it to go into a third column when it gets another 6 results




$pdf->SetXY(100,150);
$y_axis = 200;
$y2_axis = 0;
 
$sql = "select listingsdbelements_field_value from default_en_listingsdbelements where listingsdbelements_field_name = 'home_features' and listingsdb_id = '$listingID' limit 1"; 
$res = mysql_query($sql, $connection) or die(mysql_error());
 
//initialize counter
$i = 0;
 
while ($row = mysql_fetch_array($res)) {
$feature_index_list = explode("||", $row[0]);
sort($feature_index_list);
foreach($feature_index_list as $feature_list_item)
 
// prints 6 results then goes to the next cell
if ($i < 6) {
	$pdf->SetY($y_axis);
	$pdf->SetX(90);
 
	$pdf->Cell(20,4,$feature_list_item,0,1,L,'');
 
	//Go to next row
 
	$y_axis = $y_axis + 3;
	$i = $i+1;
	}
 
 
	else {
	$inity_axis = 200;
	$pdf->SetY($inity_axis+$y2_axis);
	$pdf->SetX(135);
 
 
 
	$pdf->Cell(20,4,$feature_list_item,0,1,L,'');
	$y2_axis = $y2_axis + 3;
 
	$i = $i+1;
 
 
 
	}
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ollyatstithians
ollyatstithians
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peter2001
peter2001

ASKER

Thats perfect that helps me understand it and your solution 2 works just as i need it to.

Thank you very much for your help