how to print from database

Discussion in 'PHP' started by dougvcd, Jan 31, 2008.

  1. #1
    if you use echo to print to screen
    what do you do to print to printer
    cheers
    Doug
     
    dougvcd, Jan 31, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You can't, unless the printer is connected to the web server, and you want to print to it, instead of the user's printer.

    You have to use Javascript to call the user's printer.
     
    nico_swd, Jan 31, 2008 IP
  3. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    cheers buddy
    where can i find info on how to do it
    Doug
     
    dougvcd, Jan 31, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    It works like this:

    
    <a href="javascript: window.print();">Print window</a>
    
    HTML:
     
    nico_swd, Jan 31, 2008 IP
  5. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    cheers buddy
    that worked a treat
    Doug
     
    dougvcd, Feb 1, 2008 IP
  6. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Also I recommend making a print style css class.

    Print styles are extremely important when printing from the web.

    Especially if your printing invoice data and tables.

    Anyhow here is a pretty standard one:

    print_style.css
    
    
    body
    {
        background: transparent none;
        color: #000000; /* color light grey */
        padding: 0;
        width: 100%;
    }
    
    u
    {
        border-bottom: 1px solid #000000; /* color light grey */
        text-decoration: none;
    }
    
    div#logo-print
    {
        display: block;
        padding: 0 0 30px 0;
    }
    
    div#logo-print img
    {
        margin: 0;
    }
    
    div#body
    {
        background: none;
        float: none;
        margin: -40px 0 0 0;
        width: 100%;
    }
    
    div#content
    {
        display: block;
        width: 700px; /* maximum width for printing, percentages do not work */
        margin: 0 0 0 10px;
        _margin: 10px 0 0 -10px;
    }
    
    div#body #contentHelpLinks ul
    {
        margin: 0 20%;
        _margin: 0 8%; /* IE6 fix */
    }
    
    div#body #contentHelpLinks li
    {
        width: 245px;
    }
    
    
    {
        display: none;
    }
    
    Code (markup):

    Obviously some of that code can go as it pertains to my application only but it would not be a bad idea to have a "printer friendly" version on your page.

    Just a thought thats all...
     
    LittleJonSupportSite, Feb 1, 2008 IP