orladin Posted July 5, 2007 Share Posted July 5, 2007 Hi, Let say i have 10 record. For every 3 record it used the same value starting from number 1. The output would be like this 1 1 1 2 2 2 3 3 3 4 I don't know how to put the if condition of 3 in the while statement like this <? $var1 = 0; while ($var1 < 10) { $var1++; echo $var1; } ?> please help... Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 <?php $var=0; while ($var<10) { for ($i=0;$i<3;$i++) { echo $var; $var++ if ($var>=9) {break;} } } ?> Can't think why you want to do that - bit strange but I think the above code would be what you want. Not tried it, never even written anything like it! Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 5, 2007 Share Posted July 5, 2007 since somebody already posted b4 me i can only give you an alternative from what you have described i can create this code: <?php $var = 0; while($var != 10) { $ans = 0; $var++; $ans = ceil($var/3); echo $ans; } ?> the link is: http://dreamshowstudios.net/counterhelp.php for a demo Quote Link to comment Share on other sites More sharing options...
orladin Posted July 5, 2007 Author Share Posted July 5, 2007 Yesideez, BillyBoB thanks Quote Link to comment 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.