<thead> <tr> <th>#</th> <th>Username</th> <th>Tickets</th> <th><?php echo $count ? "Total Wins" : "Winnings"; ?> </th> </tr> </thead> <tbody> <?php $dollar = $count ? "" : "\$"; $i = 0; foreach ($page->getRows() as $row) { foreach ($row as $key => $value) { if ($key == "COUNT(lottery.winnings)" || $key == "SUM(lottery.winnings)") { $key = "winnings"; } else { if ($key == "COUNT(lottery.totaltickets)" || $key == "SUM(lottery.totaltickets)") { $key = "totaltickets"; } } $row[$key] = $value; } $i++; ?> <tr> <td><?php echo $i;