我在网上发现了这个剧本,我需要修改它适合我的需要,我已经尝试了一些东西,但我在我头上要启用。PHP动态计数器?
我发现该脚本位于:http://www.daniweb.com/web-development/php/threads/68355
我需要一个类似的脚本,基本上将与数32000开始(基于假设8月22日午夜),然后通过5每10分钟上升永远。
谁能帮助我使用的例子吗?或者将我指向其他地方的现有示例?
非常感谢!我从我下面的包含链接粘贴代码:
<?php
$now = time();
$start = mktime(0, 0, 0, 1, 24, 2007);
$carbonsaving =((($now - $start) * 0.0058774) + 130000);
$format = round($carbonsaving, 2);
// in this example
// $now = a unix timestamp of this very second
// $start is the date that you want the counter to start from sent over //as a unix timestamp
// $carbonsaving is the calculation that you want to perform to get //your base figure
// i.e. total saving = ((date now - start date)* growth rate) + base rate
// this gives us the starting saving all that needs to be done is increment it with javascript
?>
<script type="text/javascript">
// we need to import our server side variable into javascript to let it increment live
var car = <?php print($format); ?>;
var rou
function incs()
{
car = car + 0.01;
rou = Math.round(car*100)/100
document.getElementById("carb").innerHTML=rou;
}
// what function incs does is take car and adds 0.01 to it
//rou rounds the figure to 2 dp
//the document.getElementById("carb") can refer to a <p> tag //<span> or whatever and just says with .innerHTML=rou; that the //value between the results of rou
//hope this helps
//Nicholas King
//ecotricity
</script>
</head>
<!-- body onload setInterval tells the page to load our javascript function and repeat it by every x microseconds, so this repeats every 2 seconds //-->
<body onload="setInterval('incs()', 2000)">
<div id="carb">Calculating...</div>
究竟你需要的是什么?如果我们知道一些背景,我们可能会更好地帮助您。 – Rijk
我试图在一个以基数开始的网站上放置一个计数器,然后继续往上走。 例如:这个很多人都在Facebook上 - 345001619,它通过x个上升每隔x分钟 – amg21