View Full Version : Printing address labels from web database
09-10-2005, 03:15 PM
I am trying to create for our school (I am one of the teachers), a web based application where we can list contacts in a mysql database. Then I can retrieve the addresses with php to a results page when we want to print address labels. Now I am unsure how to configure the results page or otherwise configure the web application to print to a sheets of avery address labels right from the php page off the web application. We have no budget (being a school of course) so I can't buy additional software...I just have to figure it out for them on my own. I have some experience with php and mysql (I have created basic contact forms and guestbook-like applications).
Any help is greatly appreciated. Thanks in advance.
well.... to put the information in the database is quite easy i think, if you need help with that i can help you. I could probably also help you with the result page but i don't exactly understand what you mean by that
09-10-2005, 04:21 PM
I can add the information to the mysql databse with no trouble. I also can create a results page where all the database info would be posted. Now, I am not sure how to get the addresses off the results page and printed to address labels on a printer. I assume if I knew how to configure the results page to be displayed like the avery label page I was going to print that could solve it. Otherwise I have no clue. I read somehwhere that you can configure a php page to send it to another program like ms word to print.
Hopefully I am more clear. Thanks for offering to help. I appreciate it and look forward to your response.
do you need to do this over the web?
if not, then just use MsAccess --> even has a report-wizard for adresslabels
09-10-2005, 04:49 PM
So if I use access for my database do I have to run access on the workstation to create the printed labels or can I still do it from the web page. ?
well, that's why i asked "do you need to do this over the web?".
if you wanna initiate the printjob from your browser, then i don't think you could use MsAccess (well, i think it would still be doable be unnescecary complex). access would be a good alternative if you just print them ofline, after you loaded the data from your mysql db.
if you wanna start the printjob from your browser, then, in my opinion, the only good way to do it is dynamically creating a pdf (through PHP, with the data from your db) that is streamed to your browser. there are a few good PHP classes that make this a very simple job. I frequently use the r&os-class ( http://www.ros.co.nz/pdf/ ) but there are of course other classes.
With pdf, you completely control your pagelayout, which is not so in html, and you can control how the adresses are split up over pages.
with the r&os-class, it's very easy to generate a table in your pdf, where rows aren't broken up over pages. so if you have 1 cell for each adress, then your adresses will always be kept on one page.
09-10-2005, 11:37 PM
There are some commands in CSS2 that allow you to set paper sizes etc for printing a web page. It should just be a matter of getting the text into the right place using the appropriate stylesheet commands which could involve a lot of trial and error. Which browser you use could also affect how well you can achieve the result as I don't think the older version 7 browsers support the page options within CSS2.
09-11-2005, 09:53 PM
Here's an idea. I know this can be done but I don't know how to command it in php. There is a php command where I can force Microsoft Word to open a template file and populate it from the database using the e-mail merge. I know this works normally if I open the templete with Word so If I can get that file to be forced open that would be cool since the workstations have Word installed on them.
What would also be cool if you could choose the entries you wanted to send to the template right in the browser by some check list or the like. However, I will leave that question for another thread. Thanks
Here's an idea. I know this can be done but I don't know how to command it in php. There is a php command where I can force Microsoft Word to open a template file and populate it from the database using the e-mail merge.
Why do you assume that this can be done?
I mean, for this to work, the word-document and template should be stored on each workstation (a maintenance-nightmare on its own) + you should be able to open a worddocument on the workstation bij the server (which would involve some form of 'remote desktop' control or maybe some sort of ActiveX-component, but it'll create a security-risk in any case) + the desktop should have access to your MySQL server (which creates an even bigger securityrisk).
It's not because you can do this on the localhost (where PHP - Apache - MySQL and Word run on the same machine) that you can just do it on every workstation.
Dynamically creating a pdf is far easier, more secure, faster and gives you more control over the pages layout.
What would also be cool if you could choose the entries you wanted to send to the template right in the browser by some check list or the like. However, I will leave that question for another thread.
This is quite easy to do if you dynamically create a pdf. you just display a form with the adresses with checkboxes next to them, and only select the adresses that were checked and then build the pdf from that recordset. Just like you would do it if you would show the adresses on screen.
09-12-2005, 03:42 PM
Let's assume that I can't get php to open the file. I have already tested the template. When it opens, the file is automatically populated from the database. If I store the template in a folder (lets call it "docs") on the sites remote server, all I want is to create a form that allows me the coice to select the addresses I want to print or select all, and when I hit the send button it sends it to a php pahe that commands the tenplate to open. Because the only people accessing this page will be ones with MS Word installed...there is not a problem with workstations.
I am open to ideas because I don't know how to accomplish this task either way. So suggestions about creating it the pdf way would be great. Let's assume I am retarded. Thanks
08-22-2006, 07:32 PM
I actually am working on exactly what you where doing as well.
Did you ever find a solution?, would you mind sharing it?
08-22-2006, 07:58 PM
Avery should provide specifics to column row and margin spacing, then just use that to create the output table.
09-19-2006, 03:36 PM
I now have a solution to this problem. I am happy to share it if anyone still needs it, providing that it is agreed that the code is not sold on. If you would like the code still please pm me or reply here and let me know.
09-21-2006, 02:10 PM
Chrissie, please post or email me your solution. I thought I would be able to do it using Cyrstal Reports but I just discovered that my server does not allow CR!
Thanks in advance.
09-21-2006, 03:09 PM
Perhaps rather than post the code that you don't want falling into evil hands, you could just explain the mechanics of your solution for future readers of this thread.
09-21-2006, 04:29 PM
Check your private messages ... I PM'd you.