Well, weed. You got me all excited. Both of the solutions seemed like simple compact solutions.
Since I didn't know anything about setting up foreign keys, I decided to first try your initial proposal.
My first attempt being:
<?php
$config_server = "******"; //Database host
$config_database = "********"; //Database name
$config_username = "********"; //Database username
$config_password = "********"; //Database password
$secret_key = "*******"; //Secret key, make it a random word/sentence/whatever
include('../adodb/adodb.inc.php'); //Include adodb files
$db = &ADONewConnection('mysql'); //Connect to database
$db->Connect($config_server, $config_username, $config_password, $config_database); //Select table
$db->SetFetchMode(ADODB_FETCH_ASSOC); //Fetch associative arrays
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Fetch associative arrays
//$db->debug = true; //Debug
$turn_increases = array(
'Member' => 15,
'Ghetto' => 30,
'Player' => 45,
'Pimp' => 60,
'OG' => 100,
//...
);
$query = $db->execute("update `players` set `turns`=turns + ".$turn_increases[$player->rank]);
?>
Well, that returned no results at all. My script was at least adding something to the turns, this did nothing.
So, I then decided to go and learn a bit about setting up foreign keys in phpmyadmin.
After about 5 articles on the subject and then one video tutorial, I was able to figure out how that worked. So, I set up the table 'ranks' added both 'rank' and 'increase' to the table while making 'rank' the primary.
I then inserted 5 new values to each row, 1 for each rank. Setting "Member" as the default. Once I had all of those done, I went and set the foreign key relationship between <b>players->rank </b>and <b>ranks->rank</b>.
Once I had all of the tables setup, I created to php script like so....
<?php
$config_server = "******"; //Database host
$config_database = "******"; //Database name
$config_username = "*******"; //Database username
$config_password = "********"; //Database password
$secret_key = "********"; //Secret key, make it a random word/sentence/whatever
include('../adodb/adodb.inc.php'); //Include adodb files
$db = &ADONewConnection('mysql'); //Connect to database
$db->Connect($config_server, $config_username, $config_password, $config_database); //Select table
$db->SetFetchMode(ADODB_FETCH_ASSOC); //Fetch associative arrays
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Fetch associative arrays
//$db->debug = true; //Debug
$query = $db->execute("update players set turns=turns+(select increase from ranks where players.rank=ranks.rank");
?>
I was sure to check and recheck everything before bringing it back here. I made sure that the foreign keys were set, the ranks in each 'rank' table matched to the letter.
And yet, I couldn't get that to work either.
My current update script looks like this.
<?php
$config_server = ""; //Database host
$config_database = ""; //Database name
$config_username = ""; //Database username
$config_password = ""; //Database password
$secret_key = ""; //Secret key, make it a random word/sentence/whatever
include('../adodb/adodb.inc.php'); //Include adodb files
$db = &ADONewConnection('mysql'); //Connect to database
$db->Connect($config_server, $config_username, $config_password, $config_database); //Select table
$db->SetFetchMode(ADODB_FETCH_ASSOC); //Fetch associative arrays
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Fetch associative arrays
//$db->debug = true; //Debug
$query = $db->execute("update `players` set `turns`=turns + 15");
?>
I have it set on a cronjob to execute every 10 minutes and it works like a champ. I just got it working yesterday. I have since got my subscriptions set up and it is time to get the turns to update each rank respectively.
I will not let it beat me, I will keep working on it. If someone see's something they think can resolve the issue, please add your input.