Jump to content

Recommended Posts

I need to echo out the same line of code out (well almost the same) a certain amount of times...

 

I tried this but it didn't work

$i = 1;
while(($i == $lvlgain)){
$i = $i+1;
$ghgh = $i+$mem[level];
echo "Congratulations! You are now level $ghgh and you gained 5 allocation points.<br>";
}

 

I hope you can see what I'm trying to do...if not I can attempt to explain in detail

Link to comment
https://forums.phpfreaks.com/topic/68251-solved-more-while-help/
Share on other sites

Well, you have an infinite loop there. If $i equals $lvlgain to start with, then the loop will never end because you make no change to the $lvlgain variable inside the loop. If they aren't equal, then the loop will never run anyway.

 

I cant really suggest what to change as i've no idea what you are trying to do.

Congratulations! You are now level 2 and you gained 5 allocation points.

Congratulations! You are now level 3 and you gained 5 allocation points.

Congratulations! You are now level 4 and you gained 5 allocation points.

Congratulations! You are now level 5 and you gained 5 allocation points.

Congratulations! You are now level 6 and you gained 5 allocation points.

Congratulations! You are now level 7 and you gained 5 allocation points.

Congratulations! You are now level 8 and you gained 5 allocation points.

Congratulations! You are now level 9 and you gained 5 allocation points.

 

Wonderful! Great thanks :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.