Jump to content

odd and even in a for loop


etrader

Recommended Posts

Change

<?php
echo "<tr class='odd'><td>...</td>";
?>

to

<?php
$class = ($class == 'odd')?'even':'odd';
echo "<tr class='$class'><td>...</td>";
?>

and put

<?php
$class = 'even';
?>

before the loop

 

Or change

<?php
echo "<tr class='odd'><td>...</td>";
?>

to

<?php
$class = ($i%2 != 0)?'odd':'even';
echo "<tr class='$class'><td>...</td>";
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.