Reputation: 802
ive this table which is updated and re-ranked every midnight , after few days i start getting this msg
Warning: Invalid argument supplied for foreach() in
in last page of pagination to fix it i used to trunk the table and run my code again then its work fine , here is my mysql statement case the issue
mysql_free_result($result);
$i = 0;
$total_amount = count($tweeps);
foreach ($tweeps as $tweep) {
$i++;
if ($total_amount == $i) {
$class = 'divrow divrowlast';
} else {
$class = 'divrow';
}
need to tips to do permanent fix
Upvotes: 0
Views: 70
Reputation: 16989
Without seeing what $tweeps
contains its hard to help. You are however missing a closing bracket. For practice you should check if $tweeps
is in fact an array though. My assumption is that $tweeps
isn't an array.
if (is_array($tweeps)) {
foreach ($tweeps as $tweep) {
$i++;
if ($total_amount == $i) {
$class = 'divrow divrowlast';
} else {
$class = 'divrow';
}
}
}
Upvotes: 1