title: Live incremental counter with variables
body: <p>I'm trying to create a live counter that would display the number of words translated live. I would feed it the start year, the current time, the number of translated words per year, and this counter would display a live count by averaging how many words are translated per year. That way I don't have to create a fake time interval to update this counter.</p>
  
  <p>I found this snippet online and I was thinking of editing it to fit my needs:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;style type="text/css"&gt;
              div.cont {
                  position: relative;
                  background-image: url(counter.gif);
                  width:160px;
                  height:110px;
                  vertical-align:text-bottom;
              }
              div.cont div.ans {
                  position: absolute;
                  bottom: 0px;
                  margin-bottom:15px;
                  margin-left:7px;
                  color:black;
                  font-family: Verdana, Tahoma, Sans-Serif;
                  font-size: 15pt;
                  line-height: normal;
              }
          &lt;/style&gt;
          &lt;?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
          ?&gt;
          &lt;script type="text/javascript"&gt;
              // we need to import our server side variable into javascript to let it increment live
              var car = &lt;? php print($format); ?&gt; ;
              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 &lt;p&gt; tag //&lt;span&gt; or whatever and just says with .innerHTML=rou; that the //value between the  results of rou
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;!-- body onload setInterval tells the page to load our javascript function and repeat it by every x microseconds, so this repeats every 2 seconds //--&gt;
  
      &lt;body onload="setInterval('incs()', 2000)"&gt;
          &lt;div class="cont"&gt;
              &lt;div class="ans"&gt; &lt;span id="carb"&gt;Calculating...&lt;/span&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Could anyone help me do this, cause I'm too bad at PHP... thanks</p>