nathanmaxsonadil Posted September 14, 2007 Share Posted September 14, 2007 is there a way so that when the loop is half done there is a new tag? Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/ Share on other sites More sharing options...
MadTechie Posted September 14, 2007 Share Posted September 14, 2007 not sure what you mean, do you break out of the loop or change the conditions ? yes you can do both.. Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348550 Share on other sites More sharing options...
wildteen88 Posted September 14, 2007 Share Posted September 14, 2007 How do you mean by half done. What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348552 Share on other sites More sharing options...
nathanmaxsonadil Posted September 14, 2007 Author Share Posted September 14, 2007 i meant if the loop did 400 results the 200th result would have extra output.... I realized I could divide it by 2 but was wondering how to make the number not a decimal number(if there was 200.5 it would be 200 instead)... Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348558 Share on other sites More sharing options...
nathanmaxsonadil Posted September 14, 2007 Author Share Posted September 14, 2007 How do you mean by half done. What are you trying to do? I'm trying to have the mysql results be split between two divs.. Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348560 Share on other sites More sharing options...
Jessica Posted September 14, 2007 Share Posted September 14, 2007 to avoid decimals use round() Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348564 Share on other sites More sharing options...
nathanmaxsonadil Posted September 14, 2007 Author Share Posted September 14, 2007 k thanks Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348566 Share on other sites More sharing options...
MadTechie Posted September 14, 2007 Share Posted September 14, 2007 can you post some code, as an idea, what about getting the number of results and divide that by 2 then if the counter is greater than that do the other thing ie if( $recnum <= ($totalrec/2)) {echo "firstset";}else{echo "lastset";} Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348567 Share on other sites More sharing options...
wildteen88 Posted September 14, 2007 Share Posted September 14, 2007 Maybe: <style> #div1, #div2 { width: 200px; float: left; } </style> <?php $max_loops = 10; $half_way = $max_loops/2; echo '<div id="div1">'; for($i = 1; $i <= $max_loops; $i++) { echo $i . '<br />'; if($i == ceil($half_way)) echo '</div><div id="div2">'; } echo '</div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69373-solved-50-loop/#findComment-348570 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.