Welcome Guest, Not a member yet? Register   Sign In
style switch in forech loop
#6

[eluser]xwero[/eluser]
Why need two classes if one is enough? You always have the normal style of the table row, table specific or not, and then you just add a class to the rows that need to have another style.
Code:
foreach($query as $i->$row)
{
$class = ($i%2)?' class="even"':'';

echo '<li id="listItem_'. $row->id.'"'.$class.'>
<div class="info"><b>'. $row->naam.'</b><br />'. $row->omschrijving.'</div>
</li>';

}
Just add a class to the false section of the condition if you want to add a class to the odd rows.


Messages In This Thread
style switch in forech loop - by El Forum - 05-27-2009, 01:40 AM
style switch in forech loop - by El Forum - 05-27-2009, 01:51 AM
style switch in forech loop - by El Forum - 05-27-2009, 02:18 AM
style switch in forech loop - by El Forum - 05-27-2009, 02:31 AM
style switch in forech loop - by El Forum - 05-27-2009, 02:33 AM
style switch in forech loop - by El Forum - 05-27-2009, 02:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB