You want an auto-incrementing variable to show up on the page? Except the database values are updating every second? Seems like an awful system to me; incredibly heavyweight on the server.
To make it easier on your poor server, grab the value from the database with PHP, and use that in a JS loop that increments 1/sec. No need to make an AJAX call every single second while the DB updates, it's redundant.
I assume you know how to get data from a database? If not, this is all you need to know
to update the value in a box every second (1000 ms).
I hope I could help, if you need anything else, please ask
Side note: You can just use $oil++;
instead of $oil=$oil+1;
EDIT: Heck with it, I'll write something
Not tested, but SHOULD work.
<<-- emphasis on the 'Not tested'!
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
$result = mysql_query("SELECT oil,money FROM mytable");
var oil = <?php echo $oil;?>;
var money = <?php echo $money;?>;
document.getElementById("money").innerHTML = parseInt(document.getElementById("money"))++;
document.getElementById("oil").innerHTML = parseInt(document.getElementById("oil"))++;
<div id="money"><?php echo $money;?></div>
<div id="oil"><?php echo $oil;?></div>
Just swap out the PHP values for your MySQL information / table name / database name and you should be good. I'm not 100% on that parseInt part, as I've never used parseInt. (Is it math.parseInt?)