Jump to content

Recommended Posts

I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work, the page hangs... what am i doing wrong here??

<?php

$number = 5;

?>

<?php

while ($number < 10){

$number = $number + 1}

?>

<?php

echo $number

//hoping for it to be 10

?>

 

before you ask, i'm trying to figure out the principal to make this work, I'm not actually trying to make a number less than 10 become 10, but I need to know how to make this work to do some things. Thanks!!

Link to comment
https://forums.phpfreaks.com/topic/177576-do-whilewoes/
Share on other sites

i guess the problem i'm having is actually because its a two part loop....i'm trying to recreate this from memory,(at school atm..) i think i'm approaching this problem the wrong way too...

 

I'm making a game, where you get energy every x minutes...so..

if you use up all your energy and then don't sign back in till like a week later or something

 

it will check your refill time to see if it is less than time(), if it is then it will add 3600 to your refill time and give you 10 energy, but the refill time will still be less than time() so it needs to keep checking if refill time < time() and while it is add 3600 to refill time && add 10 to energy...the way i have it set up now, it doesn't loop so really in this situation everytime you refresh it will add 10 to your energy and add an hour to your refill time until either max energy or refill time> time()... but when i tried to do the while loop for this, the page would just go white, and look like it got stuck... any idea? maybe there is a smarter way to do this?? thanks for helping!! i'll post more specific if still not solved when i get home

Link to comment
https://forums.phpfreaks.com/topic/177576-do-whilewoes/#findComment-936289
Share on other sites

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.