Jump to content


Photo

How do I make a script that...


  • Please log in to reply
7 replies to this topic

#1 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 26 August 2006 - 10:09 PM

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

???
Schroedinger's Cat walks into a bar.
And doesn't.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 August 2006 - 10:19 PM

use
if($hanger > 1)
{
    // decrease by 1
    $hanger--;
}

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

#3 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 26 August 2006 - 10:25 PM

Ok. How do I set up a schedule?
Schroedinger's Cat walks into a bar.
And doesn't.

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 26 August 2006 - 10:35 PM

Ok. How do I set up a schedule?


Google, perhaps?

http://www.visualcron.com/
Legend has it that reading the manual never killed anyone.
My site

#5 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 26 August 2006 - 10:36 PM

There isn't just some script I can put in that tells it do it every 24 hours?
Schroedinger's Cat walks into a bar.
And doesn't.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 August 2006 - 10:38 PM

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.

#7 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 26 August 2006 - 10:44 PM

Ok
Schroedinger's Cat walks into a bar.
And doesn't.

#8 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 26 August 2006 - 10:45 PM

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?
Schroedinger's Cat walks into a bar.
And doesn't.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users