Visitor Stats

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
AndrewB
Posts: 171
Joined: Fri Aug 22, 2003 11:15 pm
Contact:

Visitor Stats

Post by AndrewB »

Is there a good way to find out some info from the stats?

How many unique visitors per day
How many visits per day
How many articles viewed
etc...
Thorsten
Posts: 15739
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi Andrew,

do you mean a complete statistic page inside the admin section? This could be implemented in 1.4.0 if you like.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
AndrewB
Posts: 171
Joined: Fri Aug 22, 2003 11:15 pm
Contact:

Post by AndrewB »

sounds good.

A way to view interesting stats would be great :)
AndrewB
Posts: 171
Joined: Fri Aug 22, 2003 11:15 pm
Contact:

Post by AndrewB »

I wrote a stats.php page :shock:

it just shows me how many unique visitors per day that visited my faq site in the last 31 days.

MyIE2info FAQ Stats

It runs pretty slowly and there is probably many better ways to code it but it gives me some basic visitor info :)
Thorsten
Posts: 15739
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Nice page!

If you like you can post your code here...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
AndrewB
Posts: 171
Joined: Fri Aug 22, 2003 11:15 pm
Contact:

Post by AndrewB »

Here is the code. I think it should work as is for other phpMyFAQ systems also. (just change the heading in the table)

Code: Select all

<?php

	global $db, $sqltblpre;

	echo "<TABLE BORDER=0 CELLSPACING= CELLPADDING=4>";
	echo "<TR><TD colspan=3>MyIE2info FAQ</TD></TR>";
	echo "<TR><TD colspan=3>Number of Unique Visitors per Day</TD></TR>";
	echo "<TR><TD align=center>Date</TD><TD align=center colspan=2># of Visitors</TD></TR>";
	
	/* connect to the database server */
	require ("inc/data.php");
	require ("inc/database.php");
	$db = new db_mysql();
	$db->connect($mysql_server, $mysql_user, $mysql_passwort, $mysql_db);

	$time2 = mktime(23, 59, 59);
	$time1 = mktime(0, 0, 0);

	$toggle = true;
	/* Loop for 31 days */
    for ($i = 1; $i <= 31; $i++) 
    {
		$resultDB = $db->query("SELECT count(sid) FROM ".$sqltblpre."faqsessions WHERE time > '".$time1."' AND time < '".$time2."' GROUP BY ip");
		
		$formattedDate = date("D, M j, Y", $time1);

		if ($toggle)
		{	
			$toggle=false;
			echo "<TR bgcolor=#E7EBEF>";
		}
		else
		{
			$toggle=true;
			echo "<TR bgcolor=white>";
		}

		echo "<TD width=150 align=right>".$formattedDate."</TD><TD width=60 align=right>".$db->num_rows($resultDB)."</TD><TD width=30>&nbsp;</TD></TR>";

		$time2 = $time1;
		$time1 = ($time2 - (24*3600));
    }

	echo "</TABLE>";


?>
Post Reply