| | |
help with printing multiple lines print a txt file
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I guess that because your printing a receipt and you don't need an images, TEXT would probably be the best option (If it works just as well). Faster printing would indicate it's doing less work which can't be a bad thing.
You could use the function file_get_contents($filename) to get the contents of the file as a string. Try something like the following code:
That should all work I reckon, I reckon.
BTW, when do you write the contents to the file
php.net is the best place to get help on any specific function in my humble opinion.
You could use the function file_get_contents($filename) to get the contents of the file as a string. Try something like the following code:
php Syntax (Toggle Plain Text)
$text_to_print = file_get_contents('receipt.txt'); //Use this next line only if it doesn't work without it, //ie prints "Text \n\nTo print" instead of "Text \nTo print" $text_to_print = str_replace('\n', '\r\n', $text_to_print); //yada yada, printer stuff printer_write($handle, $text_to_print); //yada yada, more printer stuff
That should all work I reckon, I reckon.
BTW, when do you write the contents to the file
receipt.txt ? If it's earlier on in the script and you don't need to keep receipt.txt then you may as well skip that process. For example: php Syntax (Toggle Plain Text)
$text_to_print = ''; //load mysql info into an array using: $data = mysql_fetch_array($result, MYSQL_ASSOC); $text_to_print .= "Name: $data['name']\r\n"; $text_to_print .= "Date: $data['date']\r\n"; //etc.
php.net is the best place to get help on any specific function in my humble opinion.
Last edited by humbug; Oct 30th, 2008 at 11:08 pm. Reason: One letter makes all the difference
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
•
•
Join Date: Oct 2008
Posts: 23
Reputation:
Solved Threads: 0
hi all
having spent a large amount of time studing the ways to print using php I have finaly figured out the best solution. I have decided NOT to use the text file, but to print directly from a query to the mysql database. the function printer_draw_text is the way forward which can be used multiple times in one page.
having spent a large amount of time studing the ways to print using php I have finaly figured out the best solution. I have decided NOT to use the text file, but to print directly from a query to the mysql database. the function printer_draw_text is the way forward which can be used multiple times in one page.
![]() |
Views: 2637 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





