Hello,
A year ago I had a freelancer create a system for me which exports results from a MySQL Database to make certification cards for students. It creates a PDF using FPDI. The template he made was ONE CARD PER PDF, so very simple.
Today I find myself trying to make a 3 card template, so 3 student cards per PDF. This changes the PHP Code drastically and I am lost.
Right now, we have a foreach statement and it spits out the coordinates of each variable, as far as where it will be placed on the card.
THIS IS SAMPLE DATA. I HAVE REMOVED STUFF FOR SECURITY SO IF YOU SEE ERRORS IN QUERY, THATS WHY.
mysql_select_db($database_db, $db);
$query_rsCourseInfo = sprintf("SELECT scheduledcourses.coursedate, locations.locationname, scheduledcoursesid, locations.locationcity, locations.locationstate, instructors.instructorname, FROM scheduledcourses LEFT JOIN locations ON scheduledcourses.courselocationid = locations.locationsid LEFT JOIN instructors ON scheduledcourses.courseinstructor = instructors.instructorsid LEFT JOIN instructor_creds ON instructors.instructorsid = instructor_creds.instructor_profile_id WHERE scheduledcourses.scheduledcoursesid = %s", GetSQLValueString($colname_rsCourseInfo, "int"));
$rsCourseInfo = mysql_query($query_rsCourseInfo, $db) or die(mysql_error());
$row_rsCourseInfo = mysql_fetch_assoc($rsCourseInfo);
$totalRows_rsCourseInfo = mysql_num_rows($rsCourseInf
$pdf= new fpdi();
$pagecount = $pdf->setSourceFile("pdfcard/pdfs/3Cards.pdf");
foreach ($myprintinglist as $row_rsCourseStudents){
/* first page starts here */
$tplidx = $pdf->ImportPage(1);
$pdf->addPage();
$pdf->useTemplate($tplidx,0,0,210);
$pdf->SetFont('Arial','',12);
$pdf->SetXY(85, 5);
$pdf->Cell(0,0,'');
$pdf->SetFont('Arial','',9);
$pdf->SetXY(125, 27);
$pdf->Cell(0,0,'$studentname');
$pdf->SetXY(165, 27);
$pdf->Cell(0,0,'SAMPLE DATA);
$pdf->SetXY(125, 36);
$pdf->Cell(0,0,'City,State');
$pdf->SetXY(158, 36);
$pdf->Cell(25,0,'1-855-555-5555',0,1,"R");
}
$pdf->Output("temp.pdf", "I");
$pdf->closeParsers();
How do I get 3 different recrods within the same card? right now the foreach is creating a new PDF per record.