This topic is locked

Statistics/Tracking

1/26/2009 1:06:45 PM
PHPRunner General questions
C
Christopher author

How do I go about collecting how many times a record was viewed, and who viewed it (based on login)? Also, in the same vain, I would like to to track searches on the advanced search pages, seeing what fields/terms are used.
Thanks!

J
Jane 1/27/2009

Hi,
use View page: Before process, List page: Before processevents on the Events tab to save all changes in your log table.

Here is a sample for the view page:

global $conn,$strTableName;

$str = "select * from log_table where UserID='".$_SESSION["UserID"]."' and Table='".$strTableName."'";

$sr = db_query($str,$conn);

if ($data = db_fetch_array($rs))

{

$strUpdate = "update log_table set NumberOfViews=NumberOfViews+1 where UserID='".$_SESSION["UserID"]."' and Table='".$strTableName."'";

db_exec($strUpdate,$conn);

}

else

{

$strInsert = "insert into log_table (UserID, Table, NumberOfViews) values ('".$_SESSION["UserID"]."','".$strTableName."',1)";

db_exec($strInsert,$conn);

}

C
Christopher author 1/28/2009

Thank you Jane. How do I track advanced searches?

Hi,

use View page: Before process, List page: Before processevents on the Events tab to save all changes in your log table.

Here is a sample for the view page:

J
Jane 1/28/2009

Hi,
use List page: Before process event.

Here is just a sample:

if (@$_REQUEST["a"]=="advsearch")

{

//your code here

//all search parameters are in the $_REQUEST array

print_r($_REQUEST); //print all search parameters

}