When you see stuff on this site like friend activities, forum threads, etc. you see an alternating background from dimgray to lightgray for each 2 posts.
How could I write a program to output things selected from a database with alternating backgrounds like that?
Figured it out:
To check if a number is divisible by 2, simply use the modulus arithmetic operator.
Ex.
for($x=0; $x<=10; $x++;){
if($x % 2){
echo($x."(Odd)");
}
else{
echo($x."(Even)");
}
echo("<br/>");
}
@Phararulez That continuously fades a single background from colour to colour, which is different from alternating colour between item to item in order to provide contrast and distinction. (If you've ever seen old computer paper, that's the idea.)
Simple.
Assign a variable to alternate between 1 and 0 like this:
$grey^=1;
Make sure you put this at the start of your query.
In your query, add a style to your td. Like this:
<td style="background:<?php $grey?echo "grey":echo "white"; ?>;">
And there you go.
I know my apprehensions might never be allayed. And so I close, realizing that perhaps the ending has not yet been written...