Jump to content

how to let users print there messages with php


redarrow

Recommended Posts

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]
[!--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()
[!--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.
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.
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>";
?>

Archived

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

×
×
  • Create New...

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.