ok so in the function below i wish to first find out how many villages the user has loop through them, work out crops used and crops consumed pretty straight forward.
CODE
function evaluateCropUsage($user){
$query = "select * from population where user = $user";
$dbdata = mysql_query($query, $this->dblink);
while($row = mysql_fetch_array($dbdata)){
$this->getPop($user, $row['location']);
$cropsUsed = 0;
for($x=1;$x<6;$x++){
$cropsUsed += $this->pop[$this->dbPop[$x]] * $this->cropUsage[$x-1];
}
$totProduction = 0;
for($x=0;$x<5;$x++){
$workers = $this->pop[$this->dbFarmers[$x]];
$production = $this->farmerProduction[$x]*$workers;
$totProduction += $production;
}
$differance = $totProduction - $cropsUsed;
echo $differance;
$this->pop['crops'] += $differance;
$this->updatePopulation();
print_r($this->pop);
}
}
with the differance as above i use $this->pop['crops'] += $differance
and then update it however it comes out wierd. in the print_r it shows the second array as just Array([crops] => 0) regardless of whatever the differance was and then renames stuff to other rows its as if it copies one row into another.
its wierd and as far as im aware shouldnt be going wrong
any ideas ??