Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Need help with hit counter...

  • 05-11-2006 01:06PM
    #1
    Registered Users, Registered Users 2 Posts: 3,467 ✭✭✭


    basically, i want to use a hit counter on my homepage which displays ONLY daily views to visitors and refreshing at 12am every day GMT.

    Also, at 12am GMT, i want the daily hits from the previous day to be displayed along side those of the new day.

    how can i do this? i've googled it but with no luck.


Comments

  • Moderators, Politics Moderators, Paid Member Posts: 44,291 Mod ✭✭✭✭Seth Brundle


    design your own system using PHP/MySQL or whatever!
    Otherwise sign up to statcounter and live without the comparison bit.

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Closed Accounts Posts: 1,879 ✭✭✭heggie


    www.haveamint.com

    it wont wipe/clear your total hits every day, but it will display for each day in the past week 'total' and 'unique' hits in a list that is easy to compare


  • Registered Users, Registered Users 2 Posts: 3,467 ✭✭✭smemon


    thanks guys, but this counter is essential as it is the main part of the site. (lol, that doesn't sound good, but you'll see when i get it up and running!)

    (it's not the site in my sig).

    i can't design it, beacuse i don't have a clue what i'm doing. i wouldn't know where to start :D


  • Moderators, Politics Moderators, Paid Member Posts: 44,291 Mod ✭✭✭✭Seth Brundle


    What does your hosting a/c support in terms of languages (PHP, ASP, etc.) and databases?
    Maybe then someone could come up with a solution.

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Closed Accounts Posts: 1,200 ✭✭✭louie


    there is something simple i designed to suit me:

    first create the tables:
    CREATE TABLE `table_name` (
      `stats_id` int(11) NOT NULL auto_increment,
      `stats_page_hits` int(11) NOT NULL default '0',
      PRIMARY KEY  (`stats_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
     
    CREATE TABLE `table_name_whos_online` (
      `id` bigint(20) NOT NULL auto_increment,
      `timestamp` int(15) NOT NULL default '0',
      `ip` varchar(40) NOT NULL default '',
      `file` varchar(100) NOT NULL default '',
      PRIMARY KEY  (`id`),
      KEY `ip` (`ip`),
      KEY `file` (`file`),
      KEY `timestamp` (`timestamp`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    
    [PHP]
    //top of the page
    //page generated time
    $x_gentime = microtime();
    $x_gentime = explode('" "',$x_gentime);
    $x_gentime = $x_gentime[1] + $x_gentime[0];
    $x_pg_start = $x_gentime;
    //end of page generated
    //end of top of the page
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    //footer
    //statistics
    //total page hits
    $all_visitsSql = "select `stats_page_hits` from `table_name`";
    $rs_all_visits = ewd_query($all_visitsSql,$conn) or die(ewd_error($all_visitsSql));
    $row_all_visits = ewd_fetch_array($rs_all_visits);
    $total_page_hits = $row_all_visits;
    $sSqlU = "Update `xj_stats_total_hits` set `stats_page_hits`='".($total_page_hits+1)."'";//add 1
    $update_stats = ewd_query($sSqlU,$conn) or die(ewd_error($sSqlU));
    ewd_free_result($rs_all_visits);
    //end of total page hits
    //whois online
    //Fetch Time
    $timestamp = time();
    $timeout = $timestamp - 900;
    //Insert User
    $insert = ewd_query("INSERT INTO table_name (timestamp, ip, file) VALUES('$timestamp','".$_SERVER."','".$_SERVER."')", $conn) or die(ewd_error($insert));
    //Delete Users
    $delete = ewd_query("DELETE FROM table_name WHERE timestamp<$timeout", $conn) or die(ewd_error($delete));
    //Fetch Users Online
    $result = ewd_query("SELECT DISTINCT ip FROM table_name_whos_online", $conn) or die(ewd_error($result));
    $users = ewd_num_rows($result);
    //end of whois online
    echo "<div style='text-align:right; padding-right:3px; border-top:3px ridge #cccccc;'>
    Total Visits: ".number_format($total_page_hits,0,".",",");
    //Show Who's Online
    if($users == 1) {
    print("<br />$users User Online.\n");
    } else {
    print("<br />$users Users Online.\n");
    }
    //end of your page
    $x_gentime = microtime();
    $x_gentime = explode('" "',$x_gentime);
    $x_gentime = $x_gentime[1] + $x_gentime[0];
    $x_pg_end = $x_gentime;
    $x_totaltime = ($x_pg_end - $x_pg_start);
    $x_showtime = number_format($x_totaltime, 4, ".", "");
    echo("<br />page generated in " . $x_showtime . " seconds");
    echo "</div>";
    //end statist
    [/PHP]

    hope this helps.


  • Advertisement
Advertisement