Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Need help with hit counter...

Options
  • 05-11-2006 2:06pm
    #1
    Registered Users 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 Posts: 39,923 Mod ✭✭✭✭Seth Brundle


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


  • 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 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 Posts: 39,923 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.


  • 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