ultraloveninja Posted November 4, 2010 Share Posted November 4, 2010 Hi there! I found this code to parse a MySQL query to PDF, but it's for small address labels and I was wondering how to make it for 4x6 labels? <?php define('FPDF_FONTPATH','/home/directory/public_html/sub/font/'); require_once('fpdf.php'); //Connect to your database mysql_connect("localhost", "db_user","db_pw") or die ("Could not connect to database"); mysql_select_db("database_name") or die ("Could not select database"); $query = "SELECT employee_name, street_address, City, state, zip_code FROM employees ORDER BY `employee_name` "; $result = mysql_query($query) or die('Error, query failed'); $num_rows = mysql_num_rows($result); function PrintAddressLabels($result){ $pdf=new FPDF(); $pdf->Open(); $pdf->AddPage(); $pdf->SetFont('Arial','B',14); $pdf->SetMargins(0,0); $pdf->SetAutoPageBreak(false); $x = 0; $y = 0; $i=0; while (TRUE) { if ($row=$result[$i]) { //positions set above $LabelText = sprintf("%s\n%s %s\n%s, %s, %s", $row['employee_name'], $row['street_address'], $row['City'], $row['state'], $row['zip_code']); Avery5160($x,$y,&$pdf,$LabelText); $y++; // next row if ($y == 10 ) { // end of page wrap to next column $x++; $y = 0; if ($x == 3 ) { // end of page $x = 0; $y = 0; $pdf->AddPage(); } } $i++; //counter through result } else { // Error quit printing break; } { $pdf->Output('mailing_labels.pdf','D'); } ?> Does anyone know where I can find some good resources/tutorials that covers how to use the PDF stuff with PHP or know how I can change this up to match for 4x6 at all? Any help or info is greatly appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/217756-printing-to-4x6-labels/ Share on other sites More sharing options...
darkfreaks Posted November 4, 2010 Share Posted November 4, 2010 http://www.ibm.com/developerworks/opensource/library/os-tcpdf/index.html this uses TCPDF hope you can find some use for it Link to comment https://forums.phpfreaks.com/topic/217756-printing-to-4x6-labels/#findComment-1130321 Share on other sites More sharing options...
ultraloveninja Posted November 4, 2010 Author Share Posted November 4, 2010 Cool. Thanks for the info! I am still a n00b when it comes to PHP, so hopefully I can wrap my head around it. But it's still helps. Thanks! Link to comment https://forums.phpfreaks.com/topic/217756-printing-to-4x6-labels/#findComment-1130330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.