How to print an output...linking with printer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    How to print an output...linking with printer

    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
    Code:
    file1
    file2
    file3
    file4
    how can I basically make output file1 as an hyperlink and when user clicks it ...It should be printed.
  • ajd335
    New Member
    • Apr 2008
    • 123

    #2
    I have used the below code for the above
    [code=php]
    <?php
    $title = " Form1";
    if(isset($_POST['fname'])) { $f1 = $_POST['fname']; }
    if(isset($_POST['lname'])) { $l1 = $_POST['lname']; }
    if(isset($_POST['add'])) { $a1 = $_POST['add']; }
    if(isset($_POST['date'])) { $d1 = $_POST['date']; }
    $fullname = $l1.","." ".$f1;

    $dirname = "/home/gr/ereports/O1" ;
    $handle = opendir($dirnam e) or die('cant open');
    $ans = shell_exec("fin d /home/gr/ereports/O1/$d1* -name \"*.ps\" -exec grep -i -e $fullname {} \\; -print0 ");
    $ans1 = explode("\n",$a ns);
    foreach($ans1 as $key => $value)
    {
    $str= substr($value,0 ,56);
    print $str;
    print('<a href ="#" onclick = " print1(); return false;">Print</a>');
    echo "<br/>";
    }
    function print1()
    {
    $fin = shell_exec("lpr -Pprinter1 $str");
    }
    ?>
    [/code]
    My current $str contains the below.And thats the output from the above script...
    Code:
    /home/path to fil...../file1.ps [U]print[/U]
    /home/path to fil...../file2.ps [U]print[/U]
    /home/path to fil...../file3.ps [U]print[/U]
    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 ??

    Comment

    Working...