Printing
Moderator: General Moderators
Here is a quick and dirty example..
Code: Select all
$resource = mysql_query($query);
echo '<table>';
while ($data = mysql_fetch_assoc($resource)) {
echo '<tr><td>' . $data['fieldName'] . '</td></tr>';
}
echo '</table>';Weirdan | Please use
Thanx
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
guru,
I have done what u sent, what i want is to get a print out of the table appeared after i i do this
codingCode: Select all
$resource = mysql_query($query);
echo '<table>';
while ($data = mysql_fetch_assoc($resource)) {
echo '<tr><td>' . $data['fieldName'] . '</td></tr>';
}
echo '</table>';Thanx
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Well this is really a client side issue, not a PHP issue.
Basically you want to set the margin's to 0 as the printer will set those automatically. Set the width to AUTO so that it fit's ok on the page. There are some CSS attributes you can use to specify page breaks. Without doing research I'm not sure if you can specify headers and footers..
PHP does not have the ability to control what is sent to the printer. Maybe you could look into converting it into a PDF?
Basically you want to set the margin's to 0 as the printer will set those automatically. Set the width to AUTO so that it fit's ok on the page. There are some CSS attributes you can use to specify page breaks. Without doing research I'm not sure if you can specify headers and footers..
PHP does not have the ability to control what is sent to the printer. Maybe you could look into converting it into a PDF?
- ronverdonk
- Forum Commoner
- Posts: 34
- Joined: Sat Jun 10, 2006 7:06 am
- Location: Netherlands
Just a little sample
Sounds like you can use a little sample. Well, here it is:
A form with heading3 and 4 and a 1-line table. It will all display on the screen, but when I print it, I want h3 to print and h4 not. Of the table I want the 2nd column to print and the first one not.
By including a CSS stylesheet with the media=print option, I can handle this. Just define a class "nopr" with
"display:none" and everything on your form with class=nopr will not print.
You can apply this method to your table.
Ronald
A form with heading3 and 4 and a 1-line table. It will all display on the screen, but when I print it, I want h3 to print and h4 not. Of the table I want the 2nd column to print and the first one not.
By including a CSS stylesheet with the media=print option, I can handle this. Just define a class "nopr" with
"display:none" and everything on your form with class=nopr will not print.
Code: Select all
The PHP code
<?php
echo '<link rel="stylesheet" media="print" type="text/css" href="prtit.css" />';
echo '<h3 class="prt">I want this to be printed</h3>';
echo '<h4 class="nopr">This one will not print</h4>';
echo '<table border="0">';
echo '<th class="nopr">Amount</th><th class="prt">Description</th>';
echo '<tr><td class="nopr">100</td><td class="prt">Whatever</td></tr>';
echo '</table>';
?>
The CSS (prtit.css):
.nopr {display:none;}
.prt {font-family:verdana,sans-serif; color:#000000;}Ronald