johnwayne77 Posted February 21, 2009 Share Posted February 21, 2009 i have a classified system in which i need to implement a banner system i want to have ads after first 5 listedclassifieds i have a foreach command which lists my classifieds i don't know how to add one banner after each 5 classifieds listed.. something like incrementing var $i++ for a while loop i could have this $i = 1; while($row = mysql_fetch_array($result)){ $i++ //echo table if($i == 5){ //echo banner $i = 1; } } but i don't know what i need for a foreach loop.. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/146280-solved-foreach/ Share on other sites More sharing options...
Philip Posted February 21, 2009 Share Posted February 21, 2009 I don't know why you created a new topic when you had this one Just the same as a while, <?php $i = 1; foreach($array as $key=>$value){ $i++ //echo table if($i == 5){ //echo banner $i = 1; } } Quote Link to comment https://forums.phpfreaks.com/topic/146280-solved-foreach/#findComment-767988 Share on other sites More sharing options...
johnwayne77 Posted February 21, 2009 Author Share Posted February 21, 2009 my bad, i thought it was different for foreach now i'm reading about smarty guidelines as i need to implement the foreach incrementation through smarty thanks for the support dude! and sorry for double posting Quote Link to comment https://forums.phpfreaks.com/topic/146280-solved-foreach/#findComment-767991 Share on other sites More sharing options...
johnwayne77 Posted February 21, 2009 Author Share Posted February 21, 2009 great, {cycle} from smarty did all the job Quote Link to comment https://forums.phpfreaks.com/topic/146280-solved-foreach/#findComment-768063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.