Jump to content

Need help with generating mailing labels - php to pdf script


kahodges

Recommended Posts

I'm using the script at the link below:

http://www.ros.co.nz/pdf/user.php

 

I can get the pdf file to generate, but I'm having trouble figuring out how to get the mysql data to populate into the labels, the arrays, etc..

 

Here is the code I have so far:

<?php
## include the class
include ('class.label.inc');
## connect to the database
$host = 'localhost';
$user = 'myusername';
$password = 'mypassword';

$database = 'mydatabase';
$query = 'select * from employees';
//--------------------------------------------------

// open the connection to the db server
$link = mysql_connect($host,$user,$password);
// change to the right database
mysql_select_db($database);
// do the SQL query
$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');
while($data[] =  mysql_fetch_assoc($result)) {}

## choose a labeltype
$labeltype="Av5160";

## create a new instance of the class of that labeltype
$label= new Clabel($labeltype);

// initialize the array
$data = array();
$info=array(1=>array('line1'=>'employee_name', 'line2'=>'street_address', 'line3'=>'', 'line4'=>'City'.'state'.'zip_code'),);
reset($info); ## just to be sure

## make the labels!
$label->makeLabel($info);
?>

 

I'd really appreciate some help.

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.