Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

how to let users print there messages with php

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[code]
<?php
$message = $_POST['message'];
$printer = printer_open();
printer_write($printer, $message);
printer_close($printer);
?>
[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[!--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 6

The 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 it

printer_open()
printer_close()
printer_write()

Share this post


Link to post
Share on other sites
<a href=# onClick="window.print();">Print this page</a>

Try adding that to thte page you want to print.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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>";
?>

Share this post


Link to post
Share on other sites
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--]

Share this post


Link to post
Share on other sites

×

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.