0
Welcome Guest! Login
0 items Join Now

Help: Incremental Counter

    • Shumba's Avatar
    • Shumba
    • Newbie
    • Posts: 10
    • Thanks: 0

    Help: Incremental Counter

    Posted 14 years 1 month ago
    • Hi, My client needs a counter that increases at the moment by 253 a day, but will increase by less or more in the future depending on circumstances. I am not very clued up with Coding. Can anyone help? The counter counts what the client refers to as job days:
      Definition: Job/Person days is the ideal amount of work done by one person in one working day.

      The counter starts at their current job days total of 64 037 then the next day (64 037 + 253 = 64290) and it must automatically add on 253 every day of the month, until they get new variables for the next month.
      Am really stuck, can anyone offer any advice??
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Ignore this post [updated below]
    • Last Edit: 14 years 1 month ago by Adamck.
    • Kiss my RSS
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Just realised you only need it on a per month bases.
      Try this
      <?php
      $number = "64037";
      $d=date("d");
      if ($d=="01") {
      $jobs = "256";
      } else if ($d=="02") {
      $jobs = "512";
      } else if ($d=="03") {
      $jobs = "768";
      } else if ($d=="04") {
      $jobs = "1024";
      } else if ($d=="05") {
      $jobs = "1280";
      } else if ($d=="06") {
      $jobs = "1536";
      } else if ($d=="07") {
      $jobs = "1792";
      } else if ($d=="08") {
      $jobs = "2048";
      } else if ($d=="09") {
      $jobs = "2304";
      } else if ($d=="10") {
      $jobs = "2560";
      } else if ($d=="11") {
      $jobs = "2816";
      } else if ($d=="12") {
      $jobs = "3072";
      } else if ($d=="13") {
      $jobs = "3328";
      } else if ($d=="14") {
      $jobs = "3584";
      } else if ($d=="15") {
      $jobs = "3840";
      } else if ($d=="16") {
      $jobs = "4096";
      } else if ($d=="17") {
      $jobs = "4352";
      } else if ($d=="18") {
      $jobs = "4608";
      } else if ($d=="19") {
      $jobs = "4864";
      } else if ($d=="20") {
      $jobs = "5120";
      } else if ($d=="21") {
      $jobs = "5376";
      } else if ($d=="22") {
      $jobs = "5632";
      } else if ($d=="23") {
      $jobs = "5888";
      } else if ($d=="24") {
      $jobs = "6144";
      } else if ($d=="25") {
      $jobs = "6400";
      } else if ($d=="26") {
      $jobs = "6656";
      } else if ($d=="27") {
      $jobs = "6912";
      } else if ($d=="28") {
      $jobs = "7168";
      } else if ($d=="29") {
      $jobs = "7424";
      } else if ($d=="30") {
      $jobs = "7680";
      } else if ($d=="31") {
      $jobs = "7936";
      }
       
      $sum = $number + $jobs;
       
      echo $sum;
       
      ?>

      This works out
      day1 = 256
      day2 = 512
      and so on...

      It takes the number you started with 64037 and add a number depending on the day today.
      for example today is 20th oct so
      day 20 = 5120
      sum = 64037 + 5120


      For next month just change the $number for the new one and work out the daily increments.
    • Kiss my RSS
    • Shumba's Avatar
    • Shumba
    • Newbie
    • Posts: 10
    • Thanks: 0

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Thanks Adamck... Now I'm really dof!! thats dumb in South Africa... where do I input the above code to make it work on the site... am really clueless right now... & a little frustrated so getting dumber & dumber by the minute... please advise what I do with the code you've placed above.. thanks again
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • safest bet would be to download and install this custom php module.
      joomla-php.googlecode.com/files/mod_php1.0alpha-J15.tar.gz

      Then when its installed goto modules and filter for module type mod_php
      enter the php code above into the module and select the page, position etc...
      or if you give it a made up position e.g JOBCOUNTER
      you can do {loadposition JOBCOUNTER} within an article.
      to show it wherever you want.

      Hope this helps
    • Kiss my RSS
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • If your completely stuck PM me your admin login and where you want it to show and ill install it for you.
      Obviously change yoru admin pass after ive completed it! 8)
    • Kiss my RSS
    • Shumba's Avatar
    • Shumba
    • Newbie
    • Posts: 10
    • Thanks: 0

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Thank you so much!! ok now I feel I'm making headway... I've managed to get it work from your instructions... I've also managed to get the code below working as well.. although that counts seconds.. would you be able to advise how I an style the code you supplied, ie make it bold and centred etc.. I tried throwing in bold tags but messed it up... Can you also look at the code below and see if we can make it do what I require, just count days instead of seconds... You've helped me out a lot so if I've exhausted your patience I understand your help is greatly appreciated.
      <html>
      <head>
      <style type="text/css">
      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;
      }
       
      </style>
       
      <?php
       
      $now = time();
      $start = mktime(0, 0, 0, 19, 10, 2010);
      $carbonsaving =((($start - $now) * 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 class="cont">
      <div class="ans">
      <span id="carb">Calculating...</span>
      </div>
      </div>
      </body>
      </html>
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • at the end of the document where the echo is:
      Replace:
       
      echo $sum;
       

      With:
       
      echo "<b><center>";
      echo $sum;
      echo "</b></center>";
       

      Will that do?



      Also the code above... if your using that code within a php module you will want to remove the <html> and <body> tags!
    • Last Edit: 14 years 1 month ago by Adamck.
    • Kiss my RSS
    • Shumba's Avatar
    • Shumba
    • Newbie
    • Posts: 10
    • Thanks: 0

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Yep that works... font size and color? :oops:
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Help: Incremental Counter

    Posted 14 years 1 month ago
    • Same again but we will use a div instead this time with some styling.
      You would just put a div class and define it within your style sheet, but to keep it simple...
       
      echo "<div style='font-size:18px; font-weight:bold; color:#F00; text-align:center;'>";
      echo $sum;
      echo "</div>";
       

      This does font size, colour, weight and makes it centred.
      Ad.
    • Kiss my RSS

Time to create page: 0.057 seconds