Hey guys,
I am trying to generate a table automatically, but I am having headaches using foreach loops:
This is probably one of the first times I've actually used a foreach loop in php and I can't figure out why I keep getting errors including:
Can anyone explain this to me?
I am trying to generate a table automatically, but I am having headaches using foreach loops:
Code:
$raw_user_rankings = mysql_query("SELECT user_id, user_name, user_clan_id, user_pop, user_race
FROM users
LIMIT 120, 30
");
$user_rankings = mysql_fetch_array($raw_user_rankings);
foreach ( $raw_user_rankings as $rank ) {
echo(" <tr>
<td>" . ($i/5) . "</td>
<td><a href=\"profile.php?id=" . $rank['user_id'] . "\">" . $rank['user_name'] . "</a></td>
<td>" . $rank['user_clan_id'] . "</td>
<td>" . $rank['user_pop'] . "</td>
<td>" . ucwords($rank['user_race']) . "</td>
</tr>
");
}
Code:
Invalid argument supplied for foreach()
Comment