Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Alternating backgrounds using PHP without using loops
Old 02-17-2004, 10:22 PM Alternating backgrounds using PHP without using loops
Funkyaardvark's Avatar
Novice Talker

Posts: 6
Location: Toronto, Canada
Trades: 0
How do you change the background of table rows using PHP without having a loop? Please respond ASAP.
__________________
"Measuring a summer's day, I only find it slips away to grey. The hours they bring me pain." - Led Zeppelin
Funkyaardvark is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-17-2004, 10:40 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You can just use if's and else's, but that can be tedious so I s'pose you could just use a static variable in a function.

PHP Code:
function altColor()
{
    
$alt1 "blue";
    
$alt2 "red";
    static 
$color;

    if(!isset(
$color) || $color $alt2)
        
$color $alt1
    
else
        
$color $alt2

    
return $color;
}

// ...

echo '<td bgcolor="' altColor() . '">';
echo 
'<td bgcolor="' altColor() . '">';
echo 
'<td bgcolor="' altColor() . '">';
echo 
'<td bgcolor="' altColor() . '">';

// ... etc ... 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 02-17-2004, 10:46 PM Reply: Alternating....
Funkyaardvark's Avatar
Novice Talker

Posts: 6
Location: Toronto, Canada
Trades: 0
Will this work with images too? Because I have to work in the theme of scanlines.
__________________
"Measuring a summer's day, I only find it slips away to grey. The hours they bring me pain." - Led Zeppelin
Funkyaardvark is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Alternating backgrounds using PHP without using loops
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11786 seconds with 12 queries