redarrow Posted April 24, 2006 Share Posted April 24, 2006 advance thank you.can someone kindly point me in the correct way to print varables of members messages to a printer.example the user types a message and got the opertunety to print it cheers, with a button that says print me. Quote Link to comment Share on other sites More sharing options...
rab Posted April 24, 2006 Share Posted April 24, 2006 [code]<?php$message = $_POST['message'];$printer = printer_open();printer_write($printer, $message);printer_close($printer);?>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 24, 2006 Author Share Posted April 24, 2006 Thanks to the users post.can someone tell me is this the correct format to print pages via a printer and from message varable.How do i add a button to let the user print the message cheers.[code]<?php$message = $_POST['message'];$printer = printer_open();printer_write($printer, $message);printer_close($printer);?><form metod="post" action=""><input type="hidden" name="message"><br><input type="submit" value="print message"></form>[/code] Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 24, 2006 Share Posted April 24, 2006 give it a go and see if it works. Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 24, 2006 Author Share Posted April 24, 2006 [!--quoteo(post=367960:date=Apr 24 2006, 01:23 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 24 2006, 01:23 PM) [snapback]367960[/snapback][/div][div class=\'quotemain\'][!--quotec--]give it a go and see if it works.[/quote]Fatal error: Call to undefined function: printer_open() in C:\Program Files\Apache Group\Apache2\htdocs\collage\project\print.php on line 6The error above please help.The reason i ask its not in any refrence book i got or php.net.what the hell is the below code and were in the manual is itprinter_open()printer_close()printer_write() Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 24, 2006 Share Posted April 24, 2006 <a href=# onClick="window.print();">Print this page</a>Try adding that to thte page you want to print. Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 24, 2006 Author Share Posted April 24, 2006 [!--quoteo(post=367965:date=Apr 24 2006, 01:44 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 24 2006, 01:44 PM) [snapback]367965[/snapback][/div][div class=\'quotemain\'][!--quotec--]<a href=# onClick="window.print();">Print this page</a>Try adding that to thte page you want to print.[/quote]sorry didnt work also need to print the varable message from the database but can not get it to work. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 24, 2006 Share Posted April 24, 2006 The code by wisewood brings up the print dialogue box as expected allowing the user to print the contents of the browser.Are you just wanting to send stuff to the printer without displaying it in the browser? If you are then I'm sure there isn't a way of doing it because PHP needs to send information to the browser first.The best option you have is formatting the text in the browser and having wisewood's line of code to let the user print the page. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 24, 2006 Share Posted April 24, 2006 For example...<?php $strSQL = "SELECT * FROM messages"; if ($result = mysql_query($strSQL) or die ("The Query is broken")) { $num = mysql_num_rows($result); for($i=0;$i<$num;$i++){ $message = mysql_result($result,$i,"message"); echo "$message<br>"; echo "<a href=# onClick="window.print();">Print this page</a>";?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 24, 2006 Author Share Posted April 24, 2006 Thank you [b]wisewood[/b] got to learn that code know cheers thank you for your time.[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--] Quote Link to comment 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.