Jump to content


Photo

how to let users print there messages with php


  • Please log in to reply
9 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 April 2006 - 12:26 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 24 April 2006 - 01:49 AM

<?php
$message = $_POST['message'];
$printer = printer_open();
printer_write($printer, $message);
printer_close($printer);
?>


#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 April 2006 - 01:19 PM

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.

<?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>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 01:23 PM

give it a go and see if it works.
wisewood: proven fact, I am both wise, and wooden.

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 April 2006 - 01:27 PM

[!--quoteo(post=367960:date=Apr 24 2006, 01:23 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 24 2006, 01:23 PM) View Post[/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()
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 01:44 PM

<a href=# onClick="window.print();">Print this page</a>

Try adding that to thte page you want to print.
wisewood: proven fact, I am both wise, and wooden.

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 April 2006 - 01:56 PM

[!--quoteo(post=367965:date=Apr 24 2006, 01:44 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 24 2006, 01:44 PM) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 24 April 2006 - 01:59 PM

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.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#9 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 02:06 PM

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>";
?>
wisewood: proven fact, I am both wise, and wooden.

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 April 2006 - 02:10 PM

Thank you wisewood 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--]
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users