Created
July 12, 2016 03:59
-
-
Save softsolution/4bee3b9d51da6aecd053dc9d1e2933ce to your computer and use it in GitHub Desktop.
Создание зебры
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{*На smarty*} | |
<table> | |
<thead> | |
<tr> | |
<th>Header</th> | |
</tr> | |
</thead> | |
<tbody> | |
{foreach from=$items item=item name=foo} | |
<tr {if $smarty.foreach.foo.index % 2}class="even"{/if}> | |
<td>Lorem ipsum dolor sit amet</td> | |
</tr> | |
{/foreach} | |
</tbody> | |
</table> | |
<?php | |
//на php | |
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0" class="us_tbl"><tr class="headline"><th>Название</th>'; | |
$cont=0; | |
foreach($lists as $key=>$list){ | |
if ($cont % 2 == 0) { | |
$class='even'; | |
} else { | |
$class='gray'; | |
} | |
echo '<tr class='.$class.'><td>'.$list['title'].'</td>'; | |
$cont++; | |
} | |
echo "</table>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment