Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:52:58+00:00 2026-06-01T03:52:58+00:00

My code is a website counter ( counter.php ). It works perfectly when run

  • 0

My code is a website counter (counter.php). It works perfectly when run directly, meaning
each time you refresh the page the counter increments starting from 5754; however, when the counter.php is included in another page containing other jQuery plugins, it stops working. The counter is static then; it will show 5754 all the time.

Please help me and clarify where I am going wrong.

This section is where the incrementation (counting of the visitors) takes place:

<?php
session_start();  
if(isset($_SESSION['executed']))
$_SESSION['executed'] = $_SESSION['executed']+ 1;
else
$_SESSION['executed'] = 5754;
?>

The page itself, which is self explanatory:

<head> 
<script src="counter/js/jquery-1.7.1.j"> type="text/javascript"></script>  

Where the counter leaves:

<div class="counter-wrap"> 

    <div class="counter-number">
        &nbsp;
    </div>
</div>

<div>

An inline CSS:

<style>

.counter-wrap {
    height:18px;
    overflow:hidden;   
}

.counter-number {
    height:198px;
    width:12px;
    position:relative;
    background-image:url(http://developer.mindtouch.com/@api/deki/files/4548/=counter_ticker_bg.gif);  
    float:left;
}

</style>

And now the jQuery code:

<script type="text/javascript">
$(".counter-number").each( function(i) {
    $(this).attr('id','num'+i);    
});

function loadinput() {
    var newval = $("#numgo").val();
    loadticker(newval);
}

function loadticker(ticnum) {
    var fticnum = add_commas(ticnum);
    var numheight=18;
   addticker(fticnum);
    if (ticnum && ticnum != 0) {

        var s = String(fticnum);

        for (i=s.length;i>=0; i--)
        {
            var onum=s.charAt(i);          
            $("#num"+i).attr('value',onum);
        }

        $(".counter-number").each( function() {
            var nval=$(this).attr("value");
            if (!isNaN(nval)) {
                var nheight = Number(nval)*numheight*-1;
                $(this).animate({ top: nheight+'px'}, 1500 );
            }
            if (nval==','){
                $(this).animate({ top: '-180px'}, 1500 );
            }
        });
    }
}

function addticker(newnum) {
    var digitcnt = $(".counter-number").size();
    var nnum = String(newnum).length;
    var digitdiff = Number(nnum - Number(digitcnt));
    if (digitdiff <0) {
        var ltdig = (Number(nnum)-1);
        $(".counter-number:gt(" + ltdig + ")").remove();
    }

    for(i=1;i<=digitdiff;i++) {
        $(".counter-wrap").append('<div class="counter-number" id="num' + (Number(digitcnt+i-1)) + '">&nbsp;</div>');
    }

}

function add_commas(nStr) {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');

    }
    return x1 + x2;

}


</script>

</head>

Here is where the function is called:

<body onload="loadticker( '<?php echo $_SESSION['executed'];  ?>' ) ">

</body> 

</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:53:00+00:00Added an answer on June 1, 2026 at 3:53 am

    It doesn’t seem to me that it’s a jQuery problem. I would suggest trying to add your PHP code at the top of your code, even before you <html> opening tag.

    Try this:

    <?php
    session_start();  
    if(isset($_SESSION['executed'])) {
        $_SESSION['executed'] = $_SESSION['executed']+ 1;
    } else {
        $_SESSION['executed'] = 5754;
    }
    
    echo $_SESSION['executed'];
    
    ?>
    <html>
    <head></head>
    ...
    <body onload="loadticker('<?php echo $_SESSION['executed']; ?>')">
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our website code is written in PHP. We have very little testing in regards
I decided to code a website where each rewritten URL has its own file,
I am putting an online counter on a website, and I have run into
I am copying code from website matplotlib and pasting into the Vim editor in
Welcome, I notice that Youtube make some changes into their website code. Anyone have
I have one custom website with code created 100% by me. I need to
When I see website starter code and examples, the CSS is always in a
I am using this code in my website to show Google search results for
I am requesting the source code of a website like this: <? $txt =
I am currently adapted a code to my website's use but now I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.