SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot stuffedbuggy's Avatar
    Join Date
    Sep 2008
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Print PHP records to printer????

    I have a script that echos all current invoices using a foreach loop. For each record echoed, I'd like to print the pertinent data of the invoice to the printer. This is for a shopping cart system. I just can't seem to get it to work. Any help would be greatly appreciated.

    Code:
    <?php
    $thelistx = array(1=>'order1', 2=>'order2');
    
    foreach($thelist as $key){
    
      echo"
       <script type=\"text/javascript\">
          window.open('printinvoice.php?invoice=$key', 'invoice',
          'width=300,height=300');
       </script>
      ";
    
    }
    
    ?>
    printinvoice.php would then display a table format of all data concerning the invoice, invoking a javascriptbody onload=print()> function

    I hope this makes sense.

  2. #2
    SitePoint Zealot stuffedbuggy's Avatar
    Join Date
    Sep 2008
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone there???

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,837
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    What sort of printer do you have attached to the web server (that's the only one PHP has access to print to).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Zealot stuffedbuggy's Avatar
    Join Date
    Sep 2008
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well actually I want to print on the client side. The users of the shopping cart system won't have access to the servers printer. I've seen other cart softwares that will allow you to select all 'open orders' and print an invoice for each one with one click of a button. This is what I'm trying to accomplish.

    Thanks for responding, I was starting to give up on this.

  5. #5
    SitePoint Zealot stuffedbuggy's Avatar
    Join Date
    Sep 2008
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I found a rather simple solution:

    it can be found here

    http://www.javascriptkit.com/dhtmltu...agebreak.shtml

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,837
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Basically all you can do is to either use PHP to generate the HTML and CSS needed and then let the person print it by pressing their browser print button

    OR you use PHP to generate it as a PDF where you have far greater control of the appearance.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •