473,756 Members | 8,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

print table with background colors

I've a table in wich I've this CSS:

..oddrow{backgr ound-color:#FFFFFF}
..evenrow{backg round-color:#CCCCCC}

The oddrows are white and the even are grey.

BUT ! when I do print the table, there is nothing !!!

How to print such lines colors ? the main purpose of this table is to be
printed.
Please help !

Bob
Dec 14 '05 #1
10 7731
Try an HTML or CSS newsgroup.

Dec 14 '05 #2
Try explaining your problem more clearly.

Dec 14 '05 #3

ZeldorBlat wrote:
Try an HTML or CSS newsgroup.<html >

<head>
<title></title>
<style>

td
{
border : solid 1px blue;
}
..oddrow
{
background-color : #FFFFFF;
}
..evenrow
{
background-color : #CCCCCC;
}
#table1
{
border : solid 1px black;
}
</style>
</head>
<body>
<?php

$data = "Example of how to colour alternate lines";
$data .= "<table id='table1'>";
$colour = 0;

for($i=1;$i<26; $i++)
{
$colour = -$colour - 1;
$data .= ($colour)?'<tr class="oddrow"> ':'<tr class="evenrow" >';
$data .= "<td>&nbsp; Line $i &nbsp;</td>";
$data .= "<td>&nbsp; Colour $colour &nbsp;</td>";
$data .= '</tr>';
}
$data .= "</table>";

echo $data;
?>
</body>
</html>

Dec 14 '05 #4
What happened there?
Should have read:
ZeldorBlat wrote:
Try an HTML or CSS newsgroup.


Why? It's a programming problem.

Try this:
<html>
<head>
<title></title>
<style>

td
{
border : solid 1px blue;
}
..oddrow
{
background-color : #FFFFFF;
}
..evenrow
{
background-color : #CCCCCC;
}
#table1
{
border : solid 1px black;
}
</style>
</head>
<body>
<?php

$data = "Example of how to colour alternate lines";
$data .= "<table id='table1'>";
$colour = 0;

for($i=1;$i<26; $i++)
{
$colour = -$colour - 1;
$data .= ($colour)?'<tr class="oddrow"> ':'<tr class="evenrow" >';
$data .= "<td>&nbsp; Line $i &nbsp;</td>";
$data .= "<td>&nbsp; Colour $colour &nbsp;</td>";
$data .= '</tr>';
}
$data .= "</table>";

echo $data;
?>
</body>
</html>

Dec 14 '05 #5
"Ian B" <ia********@gma il.com> a écrit dans le message de news:
11************* *********@g49g2 00...legr oups.com...
What happened there?
Should have read:
ZeldorBlat wrote:
Try an HTML or CSS newsgroup.
Why? It's a programming problem.

Try this:
<html>
<head>
<title></title>
<style>

td
{
border : solid 1px blue;
}
.oddrow
{
background-color : #FFFFFF;
}
.evenrow
{
background-color : #CCCCCC;
}
#table1
{
border : solid 1px black;
}
</style>
</head>
<body>
<?php

$data = "Example of how to colour alternate lines";
$data .= "<table id='table1'>";
$colour = 0;

for($i=1;$i<26; $i++)
{
$colour = -$colour - 1;
$data .= ($colour)?'<tr class="oddrow"> ':'<tr class="evenrow" >';
$data .= "<td>&nbsp; Line $i &nbsp;</td>";
$data .= "<td>&nbsp; Colour $colour &nbsp;</td>";
$data .= '</tr>';
}
$data .= "</table>";

echo $data;
?>
</body>
</html>

In fact even you example doesn't print grey lines. Try to make a preview and
look what I mean.
for($i=1;$i<26; $i++)
{
$colour = -$colour - 1;
$data .= ($colour)?'<tr class="oddrow"> ':'<tr class="evenrow" >';

I've an other function, probably quicker ? (I hope)

for($line=1;$li ne<26;$line++)
echo '<td valign="top" nowrap class="'.((($li ne%2) ==
0)?"oddrow":"ev enrow").'">'

And yes, it's probably more a question for CSS or HTML group than PHP.

Thanks for your tip.

Bob
Dec 15 '05 #6

Bob Bedford wrote:
In fact even you example doesn't print grey lines. Try to make a preview and
look what I mean.


Worked when I tried it - still does, actually, just tried it - IE,
Mozilla, FireFox, Opera and Avant, on a windows/Abyss server and on
Linux/Apache - all work. Of course, it doesn't print background colours
if you have background colours turned off in, say, IE | Tools |
Internet Options - but you would have checked that, right? ;-)

try http://examples.roughian.com/altlines.php
Ian

Dec 15 '05 #7

Bob Bedford wrote:
I've an other function, probably quicker ? (I hope)

for($line=1;$li ne<26;$line++)
echo '<td valign="top" nowrap class="'.((($li ne%2) ==
0)?"oddrow":"ev enrow").'">'


OK, a challenge! If you're going for short code as opposed to
readability,

change oddrow/evenrow to c1 and c2 and use

'<tr class="c'.($i%2 ).'">';

Ian

Dec 15 '05 #8
It's a browser printing setting issue, not a php or HTML issue. I
believe most browsers default to not printing background colours.

Check out this article:
http://nemesis.lonestar.org/site/color_tips.html

It covers most browsers including Safari, Netscape, IE and Mozilla

eg.
Setting Changes for Netscape Navigator 6.x - All Platforms
Under the Edit button, select Preferences. Then click on Appearance so
that it expands/explodes, and then click on Colors.
On the Colors panel, locate the section labeled "Sometimes a document
will provide its own colors and background." Make sure that "Always use
the colors and background specified by the web page" is checked. Then
press Ok.

Dec 15 '05 #9
"Ian B" <ia********@gma il.com> a écrit dans le message de news:
11************* ********@f14g20 00...legro ups.com...

Bob Bedford wrote:
I've an other function, probably quicker ? (I hope)

for($line=1;$li ne<26;$line++)
echo '<td valign="top" nowrap class="'.((($li ne%2) ==
0)?"oddrow":"ev enrow").'">'


OK, a challenge! If you're going for short code as opposed to
readability,

change oddrow/evenrow to c1 and c2 and use

'<tr class="c'.($i%2 ).'">';


Great, I didn't think about such code ! this also save a test !
I like to save time in my script, and you just helped me. Thanks

Bob
Dec 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2691
by: RoDzZzZ | last post by:
when i try print (ctrl +p) my webpage, my printer not print the backgrounds and bgcolors of my tables.... what i need make to show the backgrounds and bgcolors in my paper when the user print the page? thankzzz
3
37215
by: Felix Natter | last post by:
hi, is there a way (html/css/javascript) to force IE to print background-colors exactly as specified in html/stylesheets? I tried to use @media print { ... } to override IE's "print background colors + images" option, but it doesn't work. Any other idea? I'd like to avoid relying on the user for setting this option.
5
4635
by: Lee K. Seitz | last post by:
I have a set of pages with a special stylesheet used to override some styles for printing. One of the things I've tried to do is reverse the colors of my navigation. On the screen, I have a black background and the navigation is red on yellow. For print, I (obviously) have a white background and wanted the navigation to be reversed (yellow on red) for better clarity. I've done print preview in IE 6, Opera 7.5, and Netscape 7.1 (all...
1
2229
by: Amirallia | last post by:
Hello, If I want to print a page with a table with cells colored in differents colors, assuming default settings in browser, when I view the page, all the colours disappear. I know that one of the default settings in my browser is 'don't print out the background colour' which is fine because this would use lots of ink, but my table cell colours anr not showing up. A idea is to replace the cell color with image, but I don't want to use
117
18571
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
4
19560
by: Amy | last post by:
I need some help. I have this table with alternate row colors. Class gray and class white. I have javascript that do highlight when mouseover row ... and onclick to select row and highlight it with another color. Also created a class called "Selected". You can only select a row at a time. My problem is, if a row is preselected, when mouseover the selected row, the selected color is screwed. Until you click on the selected row once, the...
4
4477
by: Eric Layman | last post by:
Hi, I have a table with coloured cells. I want to print out the table via IE with the coloured cells. But the outcome of the table does not have the cells coloured. Are there ways to force out the colouring of the cells in the print outs? (Either via php/asp/css or any means)
2
2008
donilourdu
by: donilourdu | last post by:
Hi I am Doni Agna Lourdu. Can any one tell me "How can I print all Web Content" But I know To print background images, open "Tools" menu in Internet Explorer, select "Internet Options", switch to "Advanced" tab and enable "Print background colors and images" in "Printing" section. But I dont want this beacuse it is browser compatable. I need a code for print whole content when I click print.
1
2118
by: rahees | last post by:
Hi all, Can anybody help me to print the repeater data from asp.net page? I am binding two columns of the repeater table. It is including the background color, which is fetching from the database. I am really stucked in this. Some javascript functions not printing the color or the table. My repeater control is below. <asp:Repeater ID="repeaterTT" runat="server"> <HeaderTemplate> <Table border="1px" id="tblTT" cellpadding="0"...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6542
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.