FPDF new page with field data change


#1

Need some help in formatting FPDF output. Upon a change in the value of the field “Class_Number”, I want records printed on a new page. Additionally, I want no more than 3 records per page printed on each page. So far all I can get is to print each record on its own page! Code is included as well as website link.

CODE:

<?php // Get user inputs $team = $_POST['TEAM']; // open registration database $username="";$password="";$database="annual_show"; mysql_connect(mysqlcluster23,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); // Select data from judging teams table $query="SELECT * FROM judging_teams WHERE Team_Number='$team' ORDER BY Team_Number ASC LIMIT 0, 500"; $result=mysql_query($query);$num=mysql_numrows($result);mysql_close(); $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Team_Number"); $f2=mysql_result($result,$i,"Lead_Judge"); $f3=mysql_result($result,$i,"Judge_1"); $f4=mysql_result($result,$i,"Judge_2"); $f5=mysql_result($result,$i,"Judge_3"); $f6=mysql_result($result,$i,"Judge_4"); $f7=mysql_result($result,$i,"Head_Clerk"); $f8=mysql_result($result,$i,"Ribbon_Clerk"); $f9=mysql_result($result,$i,"Spotter"); $f10=mysql_result($result,$i,"Observer_1"); $f11=mysql_result($result,$i,"Observer_2"); $f12=mysql_result($result,$i,"Observer_3"); $f13=mysql_result($result,$i,"Observer_4"); $i++; } require('fpdf.php'); class PDF extends FPDF { //Page header function Header() { } //Page footer function Footer() { } } $pdf = new PDF(); $pdf->AddPage('L','A4'); // document properties $pdf->SetFont('Arial','U',14); $pdf->Cell(40,10,'List of Show Entries for Team '."$team"); // Add date report run $pdf->SetFont('Arial','',10); $pdf->Setx(10); $pdf->Sety(5); $date = date("F j, Y"); $pdf->Cell(40,30,'Report date: '.$date); $pdf->SetDrawColor(0, 0, 0); //black //table header $pdf->SetFillColor(170, 170, 170); //gray $pdf->setFont("Arial","","10"); $pdf->setXY(10, 29.5); // CHANGE THESE TO REPRESENT YOUR FIELDS $pdf->Cell(20, 5, "", 1, 0, "L", 1); $pdf->Cell(40, 5, "JUDGES", 1, 0, "C", 1); $pdf->Cell(60, 5, "CLERKS", 1, 0, "C", 1); $pdf->Cell(60, 5, "OBSERVERS", 1, 0, "C", 1); $pdf->setXY(10,34.5); $pdf->Cell(20,5, "LEAD ",1,0, "R", 1); $pdf->setXY(10,39.5); $pdf->Cell(20,5, "JUDGE 1 ",1,0, "R", 1); $pdf->setXY(10,44.5); $pdf->Cell(20,5, "JUDGE 2 ",1,0, "R", 1); $pdf->setXY(10,49.5); $pdf->Cell(20,5, "JUDGE 3 ",1,0, "R", 1); $pdf->setXY(10,54.5); $pdf->Cell(20,5, "JUDGE 4 ",1,0, "R", 1); $pdf->setXY(70,34.5); $pdf->Cell(20,5, "HEAD ",1,0, "R", 1); $pdf->setXY(70,39.5); $pdf->Cell(20,5, "RIBBON ",1,0, "R", 1); $pdf->setXY(70,44.5); $pdf->Cell(20,5, "SPOTTER ",1,0, "R", 1); $pdf->setXY(130,34.5); $pdf->Cell(20,5, "1 ",1,0, "R", 1); $pdf->setXY(130,39.5); $pdf->Cell(20,5, "2 ",1,0, "R", 1); $pdf->setXY(130,44.5); $pdf->Cell(20,5, "3 ",1,0, "R", 1); $pdf->setXY(130,49.5); $pdf->Cell(20,5, "4 ",1,0, "R", 1); $pdf->SetFillColor(198, 245, 175); $pdf->setXY(30,34.5); $pdf->Cell(40,5, "$f2",1,0, "L", 1); $pdf->setXY(30,39.5); $pdf->Cell(40,5, "$f3",1,0, "L", 1); $pdf->setXY(30,44.5); $pdf->Cell(40,5, "$f4",1,0, "L", 1); $pdf->setXY(30,49.5); $pdf->Cell(40,5, "$f5",1,0, "L", 1); $pdf->setXY(30,54.5); $pdf->Cell(40,5, "$f6",1,0, "L", 1); $pdf->SetFillColor(198, 245, 175); $pdf->setXY(90,34.5); $pdf->Cell(40,5, "$f7",1,0, "L", 1); $pdf->setXY(90,39.5); $pdf->Cell(40,5, "$f8",1,0, "L", 1); $pdf->setXY(90,44.5); $pdf->Cell(40,5, "$f9",1,0, "L", 1); $pdf->SetFillColor(198, 245, 175); $pdf->setXY(150,34.5); $pdf->Cell(40,5, "$f10",1,0, "L", 1); $pdf->setXY(150,39.5); $pdf->Cell(40,5, "$f11",1,0, "L", 1); $pdf->setXY(150,44.5); $pdf->Cell(40,5, "$f12",1,0, "L", 1); $pdf->setXY(150,49.5); $pdf->Cell(40,5, "$f13",1,0, "L", 1); $pdf->setXY(10,80); $pdf->SetFont('Arial','',14); $pdf->Cell(40,10,'Judging sheets are printed sorted by Class, then Exhibit Location.'); $pdf->setXY(10,90); $pdf->Cell(40,10,'Each page contains the information for one show entry.'); $pdf->setXY(10,100); $pdf->Cell(40,10,'If an entry is mis-classified, please give the entry to the proper judging team.'); $pdf->setXY(10,110); $pdf->Cell(40,10,'Please take the time to indicate the new class to which the entry is assigned.'); $pdf->setXY(10,120); $pdf->Cell(40,10,'Please take the time to record all award information.'); $pdf->setXY(10,130); $pdf->Cell(40,10,'Upon conclusion of your work, please return your team judging sheets to registration.'); $username="";$password="";$database="annual_show"; mysql_connect(mysqlcluster23,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); // Select data from entries table $query="SELECT * FROM entries WHERE Team_Number='$team' ORDER BY Class_Number, Exhibit_Number, ENTRY_ID ASC LIMIT 0, 500"; $result=mysql_query($query);$num=mysql_numrows($result);mysql_close(); $pdf->SetFont('Arial','',14); $pdf->setXY(10,160); $pdf->Cell(40,10,'Team '."$team"); $pdf->setXY(28,160); $pdf->Cell(10,10, 'has'); $pdf->setXY(38, 160); $pdf->Cell(40,10,"$num".' entries'); $username="";$password="";$database="annual_show"; mysql_connect(mysqlcluster23,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); // Select data from entries table $query="SELECT * FROM entries WHERE Team_Number='$team' ORDER BY Class_Number, Exhibit_Number, ENTRY_ID ASC LIMIT 0, 500"; $result=mysql_query($query);$num=mysql_numrows($result);mysql_close(); $current_class=0; $i=0; $x=10; $y=10; $count=1; while ($i < $num) { if ($count==1) { $pdf->AddPage('L','A4');} $g1=mysql_result($result,$i,"ENTRY_ID"); $class_number=mysql_result($result,$i,"Class_Number"); $g3=mysql_result($result,$i,"Exhibitor_Number"); $g4=mysql_result($result,$i,"Exhibit_Number"); $g5=mysql_result($result,$i,"Plant_Name_L1"); $g6=mysql_result($result,$i,"Plant_Name_L2"); $g7=mysql_result($result,$i,"Plant_Name_L3"); $g8=mysql_result($result,$i,"Cross_Name_L1"); $g9=mysql_result($result,$i,"Cross_Name_L2"); $g10=mysql_result($result,$i,"Cross_Name_L3"); $pdf->SetFillColor(170, 170, 170); //gray $pdf->SetFont('Arial','',12); $pdf->setXY($x, $y+15); $pdf->Cell(20, 5, "XBT LOC", 1, 0, "C", 1); $pdf->setXY($x+20, $y+15); $pdf->Cell(10, 5, "$g4", 0, 0, "C", 0); $pdf->setXY($x+40, $y+15); $pdf->Cell(20, 5, "CLASS", 1, 0, "C", 1); $pdf->setXY($x+60, $y+15); $pdf->Cell(15, 5, "$class_number", 0, 0, "C", 0); $pdf->setXY($x+80, $y+15); $pdf->Cell(15, 5, "TAG", 1, 0, "C", 1); $pdf->setXY($x+95, $y+15); $pdf->Cell(15, 5, "$g1", 0, 0, "C", 0); $pdf->setXY($x+235,$y+15); $pdf->Cell(20, 5, "XBTOR", 1, 0, "C", 1); $pdf->setXY($x+255,$y+15); $pdf->Cell(10, 5, "$g3", 0, 0, "C", 0); //table header $pdf->SetFillColor(170, 170, 170); //gray $pdf->setXY($x, $y+21); $pdf->SetFont('Arial','',10); $pdf->Cell(133,5.5, "PLANT", 1, 0, "C", 1); $pdf->Cell(133,5.5, "CROSS", 1, 0, "C", 1); $pdf->setFont("Arial","","8"); $pdf->setXY($x, $y+27); $pdf->Cell(133,5.5, "$g5", 0, 0, "C", 1); $pdf->Cell(133,5.5, "$g8", 0, 0, "C", 1); $pdf->setXY($x, $y+33); $pdf->Cell(133,5.5, "$g6", 0, 0, "C", 1); $pdf->Cell(133,5.5, "$g9", 0, 0, "C", 1); $pdf->setXY($x, $y+39); $pdf->Cell(133,5.5, "$g7", 0, 0, "C", 1); $pdf->Cell(133,5.5, "$g10", 0, 0, "C", 1); $pdf->setXY($x-1, $y+60); $pdf->Cell(1,5.5, "|", 0, 0, "L", 0); $pdf->setXY($x-.5, $y+60); $pdf->Cell(133,5.5, "_______________________________________________________________________________________________________________________________________________________ __________________", 0, 0, "L", 0); $pdf->setXY($x+266, $y+60); $pdf->Cell(1,5.5, "|", 0, 0, "R", 0); $pdf->setXY($x+2, $y+55); $pdf->SetFont('Arial','',10); $pdf->Cell(23,5.5, "Place Awards (Circle)", 1, 0, "L", 1); $pdf->setXY($x+45, $y+55); $pdf->Cell(23,5.5, "FIRST SECOND THIRD", 0, 0, "L", 0); $pdf->setXY($x+100, $y+55); $pdf->Cell(25,5.5, "Best of Class?", 1, 0, "L", 1); $pdf->setXY($x+130, $y+55); $pdf->Cell(25,5.5, "Yes", 0, 0, "L", 0); $pdf->setXY($x+150, $y+48); $pdf->Cell(22,5.5, "AOS Awards", 1, 0, "L", 1); $pdf->setXY($x+150, $y+55); $pdf->Cell(26,5.5, "Special Awards", 1, 0, "L", 1); $i++; //if class changes print on next page if ($class_number!=$current_class) { $x=10; $y=10; $pdf->setxy($x,$y); $current_class=$class_number; $count = ($count + 1); } //if more than 3 entries per page print on next page if($count=3) { $x=10; $y=10; $pdf->setxy($x,$y); $count = 1; } } $pdf->Output(); ?>

Link to website is

www.gcos/org/ANNUAL_SHOW/REGISTRATION/PRINT_DATA/print_team_judging_sheets.html

Use as team input, 1,2,3, or 4


#2

Very hard to read your code. Next time post it using the correct tags.
Sometimes you need to select the code after putting into the reply and use both the preformatted and quote tags, one then the other to make it readable. Depends on where you copy them from.

Anyway, you are parsing thru all 500 of the items. You would need to do it a different way.

You set an index to zero and then loop thru all of the items up to the total. This could be 1 item or 500 since you set a limit to 500. Now, you need to keep this $i index as you are using the older version of reading data. (Not how it is normally done these days!) But, you also set a new page each time. You need to change the new page to only do it on the first of three items. Therefore, you would need a new counter for that. Let’s call it $item_count to make it clear. You would need to do it something like this:
`

$i=0;
$item_count=0;
while ($i < $num) {
if ($item_count==0) { $pdf->AddPage(‘L’,‘A4’); }
` $item_count=$item_count+1;
if ($item_count==3) { $item_count=0; }

What this does is create a new counter for the number of items on the page. They count 0,1,2.
As each item is displayed, it adds one to the counter. If it equals 3, it resets it back to zero.
In this way, it would add a new page at the first of three items and restart it’s count.

Hope that helps…


#3

I suspect that the LIMIT terms in the queries are leftover from copy/pasting this together (the first query matches a single row, so LIMIT is irrelevant) and that all matching data from the entries query should be retrieved (there should only be ONE entries query.)

You can do this without extra variables, counters, and conditional logic. Go back to your 1st thread on this forum - FPDF multiple columns on one page and retrieve all the entry data into an array (indexing/pivoting the data using the Class_Number) and use array_chunk() to break each different class number data into a maximum of 3 entries per page.

There are however a number of things you should/shouldn’t do in this code -

  1. You need to validate all input data before using it. What happens if there is no $_POST[‘TEAM’] value?

  2. Switch to use the current/modern PDO database extension - this will actually simplify and speed up the database related code since using mysql_result for each possible column is/was a waste of typing time and runs incredibly slow.

  3. Use a prepared query when supplying external/unknown data to the sql query statement

  4. Make only one database connection.

  5. I suspect the mysqlcluster23 value is a host name? if so, it is a string and should be enclosed by single-quotes. You would be getting an undefined constant error for the posted code.

  6. If a query will match at most one row (the judging_teams query), don’t use a loop to retrieve the data. Just fetch the data.

  7. Use helpful variable names that indicate the meaning of the data in the variable and don’t create unnecessary variables.

  8. Retrieve all the data from any select query into an appropriately named php variable, then just use that variable when producing the output.

For your current issue of starting a new page when the Class_Number changes and to only output three entries per page, you would index/pivot the data using the Class_number when retrieving it and use array_chunk() when producing the output from each different class number.

  1. If a query doesn’t match any data, there’s no point in running the rest of the code that’s dependent on that data. Set up user error messages when this occurs to let the user know why the code didn’t produce the expected result.

  2. Let php automatically close the database connection cor you when the script ends.

  3. Don’t use the @ error suppressor.

  4. You should have error handling for all the database statements that doesn’t unconditionally output the error information onto the web page. Once you switch to the PDO extension, this is easy. Just enable exceptions for errors when you make the connection and let php catch any exception where it will use its error_reporting, display_errors and log_errors settings to control what happens with the actual error information.

  5. Use an array to hold user error messages.

  6. List out the columns in the SELECT … term.

  7. Don’t put quotes around numbers or strings that consist of only a php variable. You can put php variables directly in a double-quoted string that includes text.

The following example code (partially tested using faked data) should work -

<?php

// get/produce data needed to display the page
if( !( isset($_POST['TEAM']) && !empty($_POST['TEAM']) ) )
{
	$errors['team'] = "A team number is required.";
} else {
	// db connection - you should put the connection code in an external .php file and require it when needed
	// shown in-line in this example
	$DB_HOST = 'mysqlcluster23';
	$DB_USER = '';
	$DB_PASS = '';
	$DB_NAME = 'annual_show';
	$DB_ENCODING = 'utf8'; // db character encoding - set to match your database tables

	$pdo = new pdo("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=$DB_ENCODING",$DB_USER,$DB_PASS);
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // set the error mode to exceptions
	$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false); // run real prepared queries
	$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); // set default fetch mode to assoc

	// Get user inputs
	$team = $_POST['TEAM']; // used in several places in the code

	// Select data from judging teams table
	$query="SELECT Lead_Judge, Judge_1, Judge_2, Judge_3, Judge_4, 
			Head_Clerk, Ribbon_Clerk, Spotter, Observer_1,
			Observer_2, Observer_3, Observer_4
	FROM judging_teams
	WHERE Team_Number=?";
	$stmt = $pdo->prepare($query);
	$stmt->execute([$team]);
	if(!$judge_data = $stmt->fetch())
	{
		$errors['judge'] = 'No Judging data was found';
	}
	
	// Select data from entries table
	$query="SELECT ENTRY_ID, Class_Number, Exhibitor_Number, Exhibit_Number,
				Plant_Name_L1, Plant_Name_L2, Plant_Name_L3, Cross_Name_L1, Cross_Name_L2, Cross_Name_L3
			FROM entries
			WHERE Team_Number=?
			ORDER BY Class_Number, Exhibit_Number, ENTRY_ID";
	$stmt = $pdo->prepare($query);
	$stmt->execute([$team]);
	$entry_data = [];
	$num = 0;
	foreach($stmt as $row)
	{
		// index/pivot the data using the Class_Number
		$entry_data[$row['Class_Number']][] = $row;
		$num++;
	}
	if(empty($entry_data))
	{
		$errors['entry'] = 'No Entry data was found';
	}
}

// produce the output
// output any errors
if(!empty($errors))
{
	echo implode('<br>',$errors);
} else {
	// no errors, produce the pdf document
	require 'fpdf.php';
	class PDF extends FPDF
	{
		//Page header
		function Header() { }
		//Page footer
		function Footer() { }
	}

	$pdf = new PDF();

	// produce the existing variables from the fetched data - you should use the original array variable the data is in, rather than to create a bunch of cryptic variables
	$f2=$judge_data["Lead_Judge"];
	$f3=$judge_data["Judge_1"];
	$f4=$judge_data["Judge_2"];
	$f5=$judge_data["Judge_3"];
	$f6=$judge_data["Judge_4"];
	$f7=$judge_data["Head_Clerk"];
	$f8=$judge_data["Ribbon_Clerk"];
	$f9=$judge_data["Spotter"];
	$f10=$judge_data["Observer_1"];
	$f11=$judge_data["Observer_2"];
	$f12=$judge_data["Observer_3"];
	$f13=$judge_data["Observer_4"];

	// output title page
	$pdf->AddPage('L','A4');
	// document properties
	$pdf->SetFont('Arial','U',14);
	$pdf->Cell(40,10,'List of Show Entries for Team '.$team);
	// Add date report run
	$pdf->SetFont('Arial','',10);
	$pdf->Setx(10);
	$pdf->Sety(5);
	$date = date("F j, Y");
	$pdf->Cell(40,30,'Report date: '.$date);
	$pdf->SetDrawColor(0, 0, 0); //black
	//table header
	$pdf->SetFillColor(170, 170, 170); //gray
	$pdf->setFont("Arial","",10);
	$pdf->setXY(10, 29.5);
	// CHANGE THESE TO REPRESENT YOUR FIELDS
	$pdf->Cell(20, 5, "", 1, 0, "L", 1);
	$pdf->Cell(40, 5, "JUDGES", 1, 0, "C", 1);
	$pdf->Cell(60, 5, "CLERKS", 1, 0, "C", 1);
	$pdf->Cell(60, 5, "OBSERVERS", 1, 0, "C", 1);
	$pdf->setXY(10,34.5);
	$pdf->Cell(20,5, "LEAD ",1,0, "R", 1);
	$pdf->setXY(10,39.5);
	$pdf->Cell(20,5, "JUDGE 1 ",1,0, "R", 1);
	$pdf->setXY(10,44.5);
	$pdf->Cell(20,5, "JUDGE 2 ",1,0, "R", 1);
	$pdf->setXY(10,49.5);
	$pdf->Cell(20,5, "JUDGE 3 ",1,0, "R", 1);
	$pdf->setXY(10,54.5);
	$pdf->Cell(20,5, "JUDGE 4 ",1,0, "R", 1);
	$pdf->setXY(70,34.5);
	$pdf->Cell(20,5, "HEAD ",1,0, "R", 1);
	$pdf->setXY(70,39.5);
	$pdf->Cell(20,5, "RIBBON ",1,0, "R", 1);
	$pdf->setXY(70,44.5);
	$pdf->Cell(20,5, "SPOTTER ",1,0, "R", 1);
	$pdf->setXY(130,34.5);
	$pdf->Cell(20,5, "1 ",1,0, "R", 1);
	$pdf->setXY(130,39.5);
	$pdf->Cell(20,5, "2 ",1,0, "R", 1);
	$pdf->setXY(130,44.5);
	$pdf->Cell(20,5, "3 ",1,0, "R", 1);
	$pdf->setXY(130,49.5);
	$pdf->Cell(20,5, "4 ",1,0, "R", 1);
	$pdf->SetFillColor(198, 245, 175);
	$pdf->setXY(30,34.5);
	$pdf->Cell(40,5, $f2,1,0, "L", 1);
	$pdf->setXY(30,39.5);
	$pdf->Cell(40,5, $f3,1,0, "L", 1);
	$pdf->setXY(30,44.5);
	$pdf->Cell(40,5, $f4,1,0, "L", 1);
	$pdf->setXY(30,49.5);
	$pdf->Cell(40,5, $f5,1,0, "L", 1);
	$pdf->setXY(30,54.5);
	$pdf->Cell(40,5, $f6,1,0, "L", 1);
	$pdf->SetFillColor(198, 245, 175);
	$pdf->setXY(90,34.5);
	$pdf->Cell(40,5, $f7,1,0, "L", 1);
	$pdf->setXY(90,39.5);
	$pdf->Cell(40,5, $f8,1,0, "L", 1);
	$pdf->setXY(90,44.5);
	$pdf->Cell(40,5, $f9,1,0, "L", 1);
	$pdf->SetFillColor(198, 245, 175);
	$pdf->setXY(150,34.5);
	$pdf->Cell(40,5, $f10,1,0, "L", 1);
	$pdf->setXY(150,39.5);
	$pdf->Cell(40,5, $f11,1,0, "L", 1);
	$pdf->setXY(150,44.5);
	$pdf->Cell(40,5, $f12,1,0, "L", 1);
	$pdf->setXY(150,49.5);
	$pdf->Cell(40,5, $f13,1,0, "L", 1);
	$pdf->setXY(10,80);
	$pdf->SetFont('Arial','',14);
	$pdf->Cell(40,10,'Judging sheets are printed sorted by Class, then Exhibit Location.');
	$pdf->setXY(10,90);
	$pdf->Cell(40,10,'Each page contains the information for one show entry.');
	$pdf->setXY(10,100);
	$pdf->Cell(40,10,'If an entry is mis-classified, please give the entry to the proper judging team.');
	$pdf->setXY(10,110);
	$pdf->Cell(40,10,'Please take the time to indicate the new class to which the entry is assigned.');
	$pdf->setXY(10,120);
	$pdf->Cell(40,10,'Please take the time to record all award information.');
	$pdf->setXY(10,130);
	$pdf->Cell(40,10,'Upon conclusion of your work, please return your team judging sheets to registration.');

	// output team's entry quantity
	$pdf->SetFont('Arial','',14);
	$pdf->setXY(10,160);
	$pdf->Cell(40,10,'Team '.$team);
	$pdf->setXY(28,160);
	$pdf->Cell(10,10, 'has');
	$pdf->setXY(38, 160);
	$suffix = $num == 1 ? 'y' : 'ies';
	$pdf->Cell(40,10,"$num entr$suffix");

	// output entry data
	// loop over the class_number data
	foreach($entry_data as $class_number=>$arr)
	{
		// break each class number data into chunks of up to 3 entries
		foreach(array_chunk($arr,3) as $chunk)
		{
			// start a new page
			$pdf->AddPage('L','A4');
			$x=10;
			$y=10;
			foreach($chunk as $row)
			{
				// output each $row/entry on the page - there will be from 1 to a maximum of 3
				
				// produce the existing variables from the fetched data - you should use the original array variable the data is in, rather than to create a bunch of cryptic variables
				$g1=$row["ENTRY_ID"];
				//$class_number=$row["Class_Number"]; // this is produced by the 1st foreach() loop
				$g3=$row["Exhibitor_Number"];
				$g4=$row["Exhibit_Number"];
				$g5=$row["Plant_Name_L1"];
				$g6=$row["Plant_Name_L2"];
				$g7=$row["Plant_Name_L3"];
				$g8=$row["Cross_Name_L1"];
				$g9=$row["Cross_Name_L2"];
				$g10=$row["Cross_Name_L3"];
				
				$pdf->SetFillColor(170, 170, 170); //gray
				$pdf->SetFont('Arial','',12);
				$pdf->setXY($x, $y+15);
				$pdf->Cell(20, 5, "XBT LOC", 1, 0, "C", 1);
				$pdf->setXY($x+20, $y+15);
				$pdf->Cell(10, 5, $g4, 0, 0, "C", 0); // exhibit number
				$pdf->setXY($x+40, $y+15);
				$pdf->Cell(20, 5, "CLASS", 1, 0, "C", 1);
				$pdf->setXY($x+60, $y+15);
				$pdf->Cell(15, 5, $class_number, 0, 0, "C", 0);
				$pdf->setXY($x+80, $y+15);
				$pdf->Cell(15, 5, "TAG", 1, 0, "C", 1);
				$pdf->setXY($x+95, $y+15);
				$pdf->Cell(15, 5, $g1, 0, 0, "C", 0); // entry id
				$pdf->setXY($x+235,$y+15);
				$pdf->Cell(20, 5, "XBTOR", 1, 0, "C", 1);
				$pdf->setXY($x+255,$y+15);
				$pdf->Cell(10, 5, $g3, 0, 0, "C", 0); // exhibitor number
				//table header
				$pdf->SetFillColor(170, 170, 170); //gray
				$pdf->setXY($x, $y+21);
				$pdf->SetFont('Arial','',10);
				$pdf->Cell(133,5.5, "PLANT", 1, 0, "C", 1);
				$pdf->Cell(133,5.5, "CROSS", 1, 0, "C", 1);
				$pdf->setFont("Arial","","8");
				$pdf->setXY($x, $y+27);
				$pdf->Cell(133,5.5, $g5, 0, 0, "C", 1);
				$pdf->Cell(133,5.5, $g8, 0, 0, "C", 1);
				$pdf->setXY($x, $y+33);
				$pdf->Cell(133,5.5, $g6, 0, 0, "C", 1);
				$pdf->Cell(133,5.5, $g9, 0, 0, "C", 1);
				$pdf->setXY($x, $y+39);
				$pdf->Cell(133,5.5, $g7, 0, 0, "C", 1);
				$pdf->Cell(133,5.5, $g10, 0, 0, "C", 1);
				$pdf->setXY($x-1, $y+60);
				$pdf->Cell(1,5.5, "|", 0, 0, "L", 0);
				$pdf->setXY($x-.5, $y+60);
				$pdf->Cell(133,5.5, "_________________________________________________________________________________________________________________________________________________________________________", 0, 0, "L", 0);
				$pdf->setXY($x+266, $y+60);
				$pdf->Cell(1,5.5, "|", 0, 0, "R", 0);
				$pdf->setXY($x+2, $y+55);
				$pdf->SetFont('Arial','',10);
				$pdf->Cell(23,5.5, "Place Awards (Circle)", 1, 0, "L", 1);
				$pdf->setXY($x+45, $y+55);
				$pdf->Cell(23,5.5, "FIRST SECOND THIRD", 0, 0, "L", 0);
				$pdf->setXY($x+100, $y+55);
				$pdf->Cell(25,5.5, "Best of Class?", 1, 0, "L", 1);
				$pdf->setXY($x+130, $y+55);
				$pdf->Cell(25,5.5, "Yes", 0, 0, "L", 0);
				$pdf->setXY($x+150, $y+48);
				$pdf->Cell(22,5.5, "AOS Awards", 1, 0, "L", 1);
				$pdf->setXY($x+150, $y+55);
				$pdf->Cell(26,5.5, "Special Awards", 1, 0, "L", 1);

				// do any any x/y modification for the next entry on the page
				$y += 55;
			}
		}
		// all entries for a class number has been output
	}
	$pdf->Output();
}
?>