ryanjones Posted April 25, 2010 Share Posted April 25, 2010 Hey everyone, Just wanted to introduce myself, I'm not a help forum user really. Well, ever. Everything I do is from books. So excuse me if this isn't the sort of thing you guys respond to... I have some data records in a database in MySQL that are generated from a web application (written, of course in PHP!) - now, I have a bit of an odd challenge ahead of me. I wish to print the record on a remote printer upon the creation of a new record. OK, so I didn't explain that too well. Site 1: Staff member inputs information into database using a form. then almost immediately... Site 2: Printer (connected to a bog standard windows box - it must be windows sadly due to double sharing hardware) then spews out the record from the MySQL database, then deletes the record. I'm really open to ideas here. I've even considered turning the form into a sendmail and then having a copy of outlook running on the windows box with a "when new mail is received -> print" rule set up, however, the major problems with that is that I need to be printing on a thermal printer from a roll of paper. This means sending a "cut" code to the printer, and of course, we're relying on email. Never a good plan. Has anyone any experience of anything like this? Any ideas how to negotiate this task? I'm aware the solution might not lie in the realm of PHP, but as that's my native lang, I thought someone else like me might have had to solve a similar problem, or can use a fresh pair of eyes to the situ which doesn't require me to try to negotiate a particularly unfamiliar language (I did some C++ in college so I may have to dust off my books...) Anyways, any ideas that you guys have, I bow down, and an open salute to you as my hero if the idea works! Thanks, Ryan Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/ Share on other sites More sharing options...
Psycho Posted April 25, 2010 Share Posted April 25, 2010 If these records have any importance I can't see how creating an automated process to print and then delete the records is, in any way, a good idea. The printer can't commnicate back to your script to verify if the record was actually printed or readable. Would it be feasible to create a script to create a printable versioin of all the currently unprinted records so a user can print those records - then verify that all the records were printed? Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/#findComment-1048160 Share on other sites More sharing options...
ryanjones Posted April 25, 2010 Author Share Posted April 25, 2010 Thanks for your reply, yeah, the records wouldn't be hard deleted after printing (they're needed for stock management), they'd be moved into an "archive" table and purged from the "current" table. BUT, you raised a very valid point. If printing failed for whatever reason, the record would be lost from the "current" table. And that isn't acceptable. HOWEVER, it isn't possible (as the windows boxes used don't have displays - or any way for us to add displays) to have a user hit that print button. An idea that I have toyed with is to have an audio alert sound - then when a printed record isn't received, then we could build in an administrative process. It's really baffling me, because it seems like i've been given a completely impossible task. The possible options don't seem workable. Is it just me, or am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/#findComment-1048169 Share on other sites More sharing options...
ChemicalBliss Posted April 25, 2010 Share Posted April 25, 2010 Well for windows environments you an use the PECL printer library. http://docs.php.net/manual/en/book.printer.php The main drawbacks of this of course is you cannot check if your page has been printed successfully, or if the printer ran out of paper (not a problem) or ink (could lose a page). You can also only print out within the functions provided, which will be quite difficult to master. Without writing a driver interface i would: 1. Have 3 tables, a: Documents, b: Pending, c: Confirmed The first is the original documents, then pending is that last set of printed docs, then confirmed is self explanatory. 2. Everytime the script prints out sheets, someone has to check them anyway (they can be numbered), so it should be a pretty simple job to mark down which pages are missing. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/#findComment-1048183 Share on other sites More sharing options...
ryanjones Posted April 25, 2010 Author Share Posted April 25, 2010 ChemicalBliss, thanks for your thoughts! I think my brain must be clearly fried... NUMBER THE PAGES! So simple, but yet so effective. Missing pages trigger the staff member to consult the supplying site by phone. You are my hero. And I can write in PHP. I will mark down 21:17 GMT as a beautiful occurrence. Right, on with the coffee, this may take a while. Thanks again to both of you for your responses! Ryan Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/#findComment-1048209 Share on other sites More sharing options...
Mchl Posted April 25, 2010 Share Posted April 25, 2010 Make sure you number them as 'page # of ##', so that it is clear how many pages are to be expected. I'm also thinking, if you can make this printer accessible over network, perhaps you can print these documents directly from your MySQL box (unless there's something on these Windows machines that is required to generate a document) Quote Link to comment https://forums.phpfreaks.com/topic/199704-conceptual-idea-getting-data-from-mysql-database-to-a-remote-printer/#findComment-1048231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.