I'm trying to fix the code of someone else. Right now I'm working on a dynamicly created table and would like to add a different class to each 2nd row. As an example the background of the 1st 3rd and 5th row should be white and the background of the 2nd 4th and 6th row grey.
Can anyone tell me how to add such 2nd class to the code?
I wasn't sure if the code would be required for this question - this is the part with a table. In case that this is not enough please let me know since my php skills are not good I'm even not sure what is need to understand the problem. As mentioned it's not my code...
$arr = array();
foreach ($them as $z => $e) {
$_them[$e['id']] = $e;
if (count($arr) < 50) {
$res = mysql_query('SELECT COUNT(*) FROM `forum_comments` WHERE `id_them` = ' . $e['id'] . '');
$row = mysql_fetch_row($res);
$total = $row[0];
$arr[$e['id']] = $total;
} else {
$res = mysql_query('SELECT COUNT(*) FROM `forum_comments` WHERE `id_them` = ' . $e['id'] . '');
$row = mysql_fetch_row($res);
$total = $row[0];
if ($total > $this->tools->array_val_min($arr)) {
$arr[$this->tools->array_key_min($arr)] = $total;
}
}
}
arsort($arr);
$arr = array_chunk($arr, 25, true);
if (!empty($_GET['p'])) {
$num = (int) $_GET['p'];
if ($num == 1) {
$arr = $arr[0];
}
if ($num > 1) {
$arr = $arr[1];
}
}
$ret = '
<table class="forum_table">
<tr class="forum_table_title">
<th id="them">' . l::themes() . '</th>
<th id="date">' . l::added() . '</th>
<th id="users">' . l::guests() . '</th>
<th id="commets">' . l::answers() . '</th>
<th id="last">' . l::last_comments() . '</th>
</tr>
<tr class="empty_td">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
';