By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

How to print an output...linking with printer

100+
P: 123
Hi ..
My result from Php scripts are no of files .
I want to link them to printer for printing.How can I do so.?
Ouput looks like
Expand|Select|Wrap|Line Numbers
  1. file1
  2. file2
  3. file3
  4. file4
how can I basically make output file1 as an hyperlink and when user clicks it ...It should be printed.
Sep 18 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 123
I have used the below code for the above
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $title = " Form1";
  3. if(isset($_POST['fname'])) { $f1 =  $_POST['fname']; }
  4. if(isset($_POST['lname'])) { $l1 =  $_POST['lname']; }
  5. if(isset($_POST['add'])) { $a1 =  $_POST['add']; }
  6. if(isset($_POST['date'])) { $d1 =  $_POST['date']; }
  7. $fullname = $l1.","." ".$f1;
  8.  
  9. $dirname = "/home/gr/ereports/O1"  ;
  10. $handle = opendir($dirname) or die('cant open');
  11. $ans = shell_exec("find /home/gr/ereports/O1/$d1*  -name \"*.ps\"  -exec grep -i -e $fullname  {} \\; -print0 ");
  12. $ans1 = explode("\n",$ans);
  13. foreach($ans1 as $key => $value)
  14. {
  15. $str=  substr($value,0,56);
  16. print $str;
  17. print('<a  href ="#" onclick = " print1(); return false;">Print</a>');
  18. echo "<br/>";
  19. }
  20. function print1()
  21. {
  22. $fin = shell_exec("lpr -Pprinter1 $str");
  23. }
  24. ?>
  25.  
My current $str contains the below.And thats the output from the above script...
Expand|Select|Wrap|Line Numbers
  1. /home/path to fil...../file1.ps print
  2. /home/path to fil...../file2.ps print
  3. /home/path to fil...../file3.ps print
  4.  
Now I want to do something so that when I click on print It should print the desired file on which It was clicked.
I am not getting the proper one...
Whats wrong in that ??
Sep 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.