lil help plz about auto color

Started on the old forum in March 2009 · view the original in the archive · old links redirect here

3 replies · 540 views · started 17 years ago · 1 min read

2 participants
alesh Lead · 604 posts #1

okay i know that title of this topic is not explaining what i want so ill try explain it bellow

if i have this code on page (its not the whole code but ull get what i want)

while ($what = mysql_fetch_array($bla))
    {
     echo "<div class=\"links\"><a href=\"video.php?id=$what[0]\">".htmlspecialchars($what[3])."</a></div><br/>";
    }

so on the page this will put all the links one after another... which is okay, i want that lol but i also want every 2nd background to be another color!

example:

1st link BLACK BACKGROUND color
2nd link WHITE BACKGROUND color
3rd link BLACK BACKGROUND color
4th link WHITE BACKGROUND color

i hope u understand what i want and i would be greatful 4 any help

eeeeerrr....

Anshul Senior · 296 posts #3

alesh wrote: okay i know that title of this topic is not explaining what i want so ill try explain it bellow

if i have this code on page (its not the whole code but ull get what i want)

while ($what = mysql_fetch_array($bla))
    {
     echo "<div class=\"links\"><a href=\"video.php?id=$what[0]\">".htmlspecialchars($what[3])."</a></div><br/>";
    }

so on the page this will put all the links one after another... which is okay, i want that lol but i also want every 2nd background to be another color!

example:

1st link BLACK BACKGROUND color
2nd link WHITE BACKGROUND color
3rd link BLACK BACKGROUND color
4th link WHITE BACKGROUND color

i hope u understand what i want and i would be greatful 4 any help

it is easy to do

while ($what = mysql_fetch_array($bla))
    {
      $I++;
      if(is_integer($I / 2)) $row = "<div class='iblock'>"; else $row = "<div>";
      echo"$row";
     echo "<div class=\"links\"><a href=\"video.php?id=$what[0]\">".htmlspecialchars($what[3])."</a></div><br/>";
     echo'</div>';
    } 
alesh Lead · 604 posts #4

thanX workS fiiiiiine!!!!

eeeeerrr....

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close