CageyJ0nnY Posted October 20, 2009 Share Posted October 20, 2009 hi guys, This may sound trivial but im new to php and as part of an assignmenti have to construct the 10 green bottles song using the do while statement. I can do the statement but it is itengrating the text (verses of the song ) into the loop. Many thanks John Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/ Share on other sites More sharing options...
Bricktop Posted October 20, 2009 Share Posted October 20, 2009 Hi CageyJ0nnY, Could you post the code you're using? Without that it's difficult for anyone to give a definitive answer. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940379 Share on other sites More sharing options...
CageyJ0nnY Posted October 20, 2009 Author Share Posted October 20, 2009 Unfortunatley im not at home at the moment, once i get back i can post the code. cheers for taking an interest Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940380 Share on other sites More sharing options...
CageyJ0nnY Posted October 20, 2009 Author Share Posted October 20, 2009 my code at the moment is <?php $counter = 10; echo "There are $counter green bottles sitting on the wall"; echo" and if one green bottle should accidentley fall there would be $counter green bottles sitting on the wall"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940569 Share on other sites More sharing options...
mikesta707 Posted October 20, 2009 Share Posted October 20, 2009 not tested, but this should work out $counter = 10; do { echo "There are $counter green bottles sitting on the wall"; $counter--; echo " and if one green bottle should accidentley fall there would be $counter green bottles sitting on the wall"; } while ($counter > 0); Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940574 Share on other sites More sharing options...
Dorky Posted October 20, 2009 Share Posted October 20, 2009 $counter = 10 ; while ($counter > 1 ) { echo "$counter green bottles"; $counter -- ; } Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940584 Share on other sites More sharing options...
CageyJ0nnY Posted October 20, 2009 Author Share Posted October 20, 2009 ahhh, i can see now were i have gone wrong. thanks for all the help =] Quote Link to comment https://forums.phpfreaks.com/topic/178341-do-while-statement/#findComment-940587 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.