Page 1 of 1
{Solved}:How can i give everyline a special css?
Posted: Fri Apr 13, 2012 8:52 am
by mekha
How can i give everyline a special css?
i have a categories:
for example:
devnetwork
google
yahoo
..
i need every category (line)
in a different style ?
maybe "while" but i dont know how to use?!
Re: How can i give everyline a special css?
Posted: Fri Apr 13, 2012 9:07 am
by Celauran
Where are these categories coming from? How are you displaying them? Please post some code and provide a little more detail about what you're trying to do.
Re: How can i give everyline a special css?
Posted: Fri Apr 13, 2012 9:12 am
by mekha
Code: Select all
<?php
$result3 = get_all_cats();
foreach($result3 as $lkey=>$lval)
{
echo '<li class="color"><a href="categories.php?cat='.$lval['Id'].'"><img src="images/page_bg.gif" width="4" height="4" border="0" alt=""> '.$lval['category_name'].'</a></li>';
}
?>
this is my code that shows the category...
i need every line of category be another background color (class)
..
http://topline.me/shop2
if u see the categories above (left)...the same style..
i need
1
2
1
2
1
2
1=style1
2=style2
Re: How can i give everyline a special css?
Posted: Fri Apr 13, 2012 9:27 am
by Celauran
So you don't want every line to have a different class, you just want to alternate between 2.
Code: Select all
<?php
$result3 = get_all_cats();
$i = 1;
foreach($result3 as $lkey=>$lval)
{
$class = ($i % 2 == 0) ? 'class1' : 'class2';
echo '<li class="'.$class.'"><a href="categories.php?cat='.$lval['Id'].'"><img src="images/page_bg.gif" width="4" height="4" border="0" alt=""> '.$lval['category_name'].'</a></li>';
$i++;
}
?>
Re: How can i give everyline a special css?
Posted: Fri Apr 13, 2012 9:34 am
by mekha
GREAT MAN ... THANK YOU!