Foreach loop is running n times
Posted
by
Furqan Khyraj
on Stack Overflow
See other posts from Stack Overflow
or by Furqan Khyraj
Published on 2012-09-23T21:29:51Z
Indexed on
2012/09/23
21:37 UTC
Read the original article
Hit count: 337
foreach($CarAdList as $CarAd)
{
echo($msg .= '<tr><td>'.$CarAd->getCarAdID().'</td><td>' .$CarAd->getBrandText().'</td><td>' .$CarAd->getDescription(). '</td><td><a href="status.php?id='.$CarAd->getCarAdID().'"><img src="../images/active.png" /></a></td><td><img src="../images/delete.png" width="30px" /></td></tr>');
}
e.g, the number of rows =38
n= the number of rows * the number of rows--
it is running n times
so its displaying
5
5
4
5
4
3
5
4
3
2
5
4
3
2
1
© Stack Overflow or respective owner