dennismonsewicz Posted January 12, 2009 Share Posted January 12, 2009 I am having a little trouble having my script increment by 5 <?php for($i=5; $i<50; $i++) { echo '<option value="' . $i . '">' . $i . '</option>'; } ?> It is incrementing 5-49; i need 5, 10, 15, 20->all the way to 50 Help? Link to comment https://forums.phpfreaks.com/topic/140566-solved-incrementing-by-5-help/ Share on other sites More sharing options...
DeanWhitehouse Posted January 12, 2009 Share Posted January 12, 2009 Say Please <?php for($i=5; $i<=50; $i+5) { echo '<option value="' . $i . '">' . $i . '</option>'; } ?> Should work, if not then do <?php $i = 5; while($i <= 50) { echo '<option value="' . $i . '">' . $i . '</option>'; $i += 5; } ?> Link to comment https://forums.phpfreaks.com/topic/140566-solved-incrementing-by-5-help/#findComment-735589 Share on other sites More sharing options...
dennismonsewicz Posted January 12, 2009 Author Share Posted January 12, 2009 please and thank you The first one creates an inifinte loop... I tried that right before seeing your post... FF crashed... I was like wtf? but the second one works like a charm! Sweet! Thanks! Link to comment https://forums.phpfreaks.com/topic/140566-solved-incrementing-by-5-help/#findComment-735593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.