Jump to content

Archived

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

Pi_Mastuh

Need help with a complex PHP code

Recommended Posts

I'm making a virtual pet site of sorts. I have the hunger of the pets stored as an integer 1 - 5. I need to make it increase by 1 every 24 hours or so. Then I need to make a list box that drops down with the number of pets the user has, with each one as an option. Then when you click on the pet, it gets rid of the food item associated with the list box and decreases the pet's hunger by 1. I have no idea how to do that though, does anyone know how I could do this? I don't know where to start...

Thanks!  :D

Share this post


Link to post
Share on other sites
That's about several hundred questions, so I'll give you a starter on the 'every 24 hours' part.  Check you web host server control panel to see if/how a cron task can be run.  Cron tasks can be automatically scheduled to run at any recurring time you want.  If you are unfortunate enough to be running on a Windoze server, you'll need to look at the scheduler (whatever they call it) for the same functionality.

Share this post


Link to post
Share on other sites
An alternative methode of doing this would just having it check at the beginning of a show hunger request. Have something like...

$var = current time (in seconds) - time last fed (in seconds);
$lost_hunger = floor($var/(60*60*24));

if ($lost_hunger > $hunger_left) $pet = dead!;

then subtract that from the current hunger


Share this post


Link to post
Share on other sites

×

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.