#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    3

    Need help with printing a report using PHP


    Hi!

    I am a relative newbie to PHP.

    I have successfully stored data in MySQL tables using PHP script that uses Form. I can also see the data on the screen when it is fetched using mysql commands. I am using PHP 5.4.3 and MySQL 5.5.24.

    Now, I want the same screen display of the data (that appears neatly in columns) to be printed like a report on a local printer. How do I go about it?

    Any clues, help will be greatly appreciated!

    Thanks in advance!
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Um, how about pressing ctrl + p in your browser?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    3
    Originally Posted by Jacques1
    Um, how about pressing ctrl + p in your browser?
    Tried, but it prints EVERYTHING! That includes, images, any buttons, menus etc.!
  6. #4
  7. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    Write a stylesheet for printing which hides whatever you wouldn't want printed. To be clear I mean to keep your site exactly as it is and make the stylesheet hide things, not to write a complete replacement for the "main" stylesheet.

    Then "@media print" it or reference it with
    Code:
    <link rel="stylesheet" type="text/css" href="/path/to/file.css" media="print" />
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    3
    Originally Posted by requinix
    Write a stylesheet for printing which hides whatever you wouldn't want printed. To be clear I mean to keep your site exactly as it is and make the stylesheet hide things, not to write a complete replacement for the "main" stylesheet.

    Then "@media print" it or reference it with
    Code:
    <link rel="stylesheet" type="text/css" href="/path/to/file.css" media="print" />
    THANKS!!! Looks easy! Will try it out!

IMN logo majestic logo threadwatch logo seochat tools logo