CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 14th, 2003, 03:38 AM
ohnder ohnder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 78 ohnder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 6 m 48 sec
Reputation Power: 11
styles.css in php

Hi

I have a table with results, all rows are displayed in one colour.. as of below... but how can I get the background-color displayed every two rows only?

tr, td {
font-family: <?php print($VISUALS[$SkinID]['page']['font']); ?>;
font-color: <?php print($VISUALS[$SkinID]['page']['color']); ?>;
font-size: <?php
print($VISUALS[$SkinID]['page']['fontsize']);
print($VISUALS[$SkinID]['page']['fontunit']);
?>;
background-color: <?php print($VISUALS[$SkinID]['page']['background-color']); ?>;
}

from visuals.inc:

$VISUALS[0]['page']['background-color'] = '#E9E9E9';
__________________
johnno

Reply With Quote
  #2  
Old February 14th, 2003, 12:43 PM
markpar76's Avatar
markpar76 markpar76 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Georgia
Posts: 102 markpar76 User rank is Corporal (100 - 500 Reputation Level)markpar76 User rank is Corporal (100 - 500 Reputation Level)markpar76 User rank is Corporal (100 - 500 Reputation Level)markpar76 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 16 h 1 m 18 sec
Reputation Power: 13
Here's some code I use to alternate row color:

while($row = mysql_fetch_array($result)) {
if(($counter % 2) == 0) {
$rcolor = "#EFEFEF";
}
else {
$rcolor = "#DDDDDD";
}
echo"
<tr bgcolor='$rcolor'>
<td>

</td>
</tr>
and so on......
";

$counter++;
}

Hope this helps. I know it's not css, but it is an easy way to do it.

Reply With Quote
  #3  
Old February 14th, 2003, 12:47 PM
munkfish's Avatar
munkfish munkfish is offline
funky munky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2001
Location: UK
Posts: 1,446 munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 18 h 45 m 36 sec
Reputation Power: 14
If you setup two different CSS ids:

.tr0 {
background-color: <?php print($VISUALS[$SkinID]['page']['background-color0']); ?>;
}

.tr1 {
background-color: <?php print($VISUALS[$SkinID]['page']['background-color1']); ?>;
}

then in the code where you output the rows of your table (presuming they're coming from an array of results):

PHP Code:
 $toggle=0;
foreach(
$row_array as $row){    
    print(
"<tr id=tr$toggle><td>$row[0]</td><td>$row[1]</td></tr>\n");
    
$toggle=($toggle+1)%2;


you should get the effect you're after (although I'm no CSS master, so you'd have to figure that out - hey what you expect on a php forum;-)

EDIT: the $toggle=($toggle+1)%2 just sets the value of $toggle to 0 if it's current value is 1 and vice-versa.

Last edited by munkfish : February 14th, 2003 at 06:11 PM.

Reply With Quote
  #4  
Old February 14th, 2003, 04:57 PM
Sh0t Sh0t is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 3 Sh0t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
As said above, define 2 elements iny our css file, then during the loop to get your results from the mysql db, just insert a little if statement with a counter var to exchange the colors on odd/even etc.

Good luck to you

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > styles.css in php

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap