I know there’s something wrong with my code because the page never loads so there’s somethign wrong with either the for loop or foreach loop. The topRankings variable is set correct and giving the right value.
<?php
for ($i = 0; $i >= count($topRankings); $i++){
foreach($topRankings[$i] as $k=>$v)
{
$seperator = ($elements == $count) ? '' : '<hr />';
$name = (!isset($row['character_name'])) ? 'TBD' : $row['character_name'];
$count++;
?>
<li><span class="red"><?php echo $name; ?></span></li>
<?php
}
}
?>
Print_r of $topRankings
Array ( [0] => Array ( [character_name] => Kid Wonder ) [1] => Array ( [character_name] => Ryu Satoshi ) [2] => Array ( [character_name] => Oriel ) [3] => Array ( [character_name] => \"The Ladies Man\" Luscious Landon ) [4] => Array ( [character_name] => \"The Outlaw\" Mike Mayhem ) )
EDIT:
I’m getting an undefined count variable and undefined variable elements and undefined offset: 5.
<?php
$count = count($topRankings);
for ($i = 0; $i <= $count; $i++) {
foreach($topRankings[$i] as $k=>$v)
{
$seperator = ($elements == $count) ? '' : '<hr />';
$name = (!isset($row['character_name'])) ? 'TBD' : $row['character_name'];
$count++;
?>
<li><span class="red"><?php echo $name; ?></span></li>
<?php
}
}
?>
This:
Should be: