Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2007-08-17, 04:21 PM
Junior Member
 
Join Date: Aug 2007
Posts: 4
wiebe81 is on a distinguished road
Question auto update

*WHAT I HAVE*

CREATE TABLE Players
(
Person varchar(12)
Policy char(12)
Tax int(2)
)

INSERT INTO Players (Person,Policy,Tax)
VALUES (Adam,domestic,9)
VALUES (Burt,military,8)
VALUES (Carol,agricultural,7)

CREATE TABLE Towns
(
Owner
Place
Population
Building
)

INSERT INTO Towns (Owner,Place,Population,Building)
VALUES (Adam,London,15000,Cathedral)
VALUES (Burt,York,5000,Chapel)
VALUES (Carol,Norwich,6000,Church)

*WHAT I WANT TO DO*

I want to automatically update this each day, where one day is equal
to one year.

If the policy is domestic, growth is 3%
If the policy is agricultural, growth is 2%
If the policy is military, growth is 1%

plus

If a cathedral is present, growth is an additional 10%
If a cathedral is present, growth is an additional 5%
If a cathedral is present, growth is an additional 2%

minus

If the tax is 1, then growth is decreased by 1%
(the maximum tax is 20)
Now for example in year 1, I have a population of 15000 in London.
In year 2 this ought to be a population of 15600.

*THE PROBLEM*

I know how to do the population growth calculation with PHP, that's the easy part. Unfortunately since I'm quite new at this, I have no clue, on how to make the tables automatically update the population figure daily. This has to happen each day, wether the user logs in or not. As the reader understands by now, I want to use this in a small multiplayer game I'm trying to create.

So how do I do this? Any help will be greatly appreciated. Thanks in advance.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2007-08-19, 10:40 PM
Junior Member
 
Join Date: Aug 2007
Posts: 4
wiebe81 is on a distinguished road
Default

I've been hearing elsewhere that's not possible to do it automatically, but that can be done when people upload a page with a timestamp. I tried looking at some tutorial, but I can't seem to make head or tails with this one on how that is stored in a database.

So suppose:

UPDATE t
SET Population = Population * CASE p.Policy
WHEN 'domestic' THEN 1.03
WHEN 'agricultural' THEN 1.02
WHEN 'military' THEN 1.01
END
FROM Towns t JOIN Players p ON (t.Owner = p.Person);


ok so then if stored

INSERT test_timestamp DEFAULT VALUES

how then does one go about changing it, would that be as simple as t+1 or something?
Reply With Quote
  #3 (permalink)  
Old 2007-08-20, 03:08 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

use cron to run your script each morning.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #4 (permalink)  
Old 2007-08-21, 10:09 AM
Junior Member
 
Join Date: Aug 2007
Posts: 4
wiebe81 is on a distinguished road
Default

ok thanks, but you wouldn't know of one for windows, now would you?
Reply With Quote
  #5 (permalink)  
Old 2007-08-22, 09:14 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

*points to his signature* Get a real webserver......

Ok, got that out of my system....I think there is a cron service for Windows. (Cron) M$ may have something native, but I dont know what that is for the previously mentioned reason.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #6 (permalink)  
Old 2007-11-22, 08:23 AM
Junior Member
 
Join Date: Nov 2007
Posts: 1
Silver is on a distinguished road
Default

The native tool for scheduling process execution in Windows is the Scheduled Tasks that you can find in the Control Panel. I'd recommend using it more than Cron.

Windows is not a bad server OS.

Hope this helps.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:30 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.