Jump to content

[SOLVED] More while help


almightyegg

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 :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.