...Ok then!
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 do what I said in Javascript, load the variable with PHP into a JS variable. From then on, use
setInterval() 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'!
Code:
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT oil,money FROM mytable");
$result=mysql_fetch_array($result);
list($oil,$money)=$result;
?>
<script type="text/javascript">
var oil = <?php echo $oil;?>;
var money = <?php echo $money;?>;
function addone(){
document.getElementById("money").innerHTML = parseInt(document.getElementById("money"))++;
document.getElementById("oil").innerHTML = parseInt(document.getElementById("oil"))++;
}
setInterval("addone()",1000);
</script>
<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?)