Jump to content

Archived

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

Pi_Mastuh

How do I make a script that...

Recommended Posts

I need a script that tells it if the number is greater then 1 then to decrease by 1 every 24 hours. How would I code that? I'm guessing something like

<? if $hunger <1 then -1 ?>

but i have no idea if thats right. And it also doesn't tell it do it every 24 hours...

???

Share this post


Link to post
Share on other sites
use
[code=php:0]if($hanger > 1)
{
    // decrease by 1
    $hanger--;
}[/code]

Now to run it every 24 hours you'll want to setup a cron tab (unix servers) or Schedule (Windows)

Share this post


Link to post
Share on other sites
[quote]Ok. How do I set up a schedule?[/quote]

Google, perhaps?

http://www.visualcron.com/

Share this post


Link to post
Share on other sites
There isn't just some script I can put in that tells it do it every 24 hours?

Share this post


Link to post
Share on other sites
No. PHP runs on a per request basis. Meaning PHP will run when a request to a PHP file is made. A schedule is the only option to run a PHP script at a  specific time.

Share this post


Link to post
Share on other sites
Also, how do I make a list box that drops down with all the items in a database row belonging to that user, and then it increases the number in a field for the item they selected. I know that to increase it would be $hunger++ but how do I do the list box thing?

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.