This topic is locked
[SOLVED]

 Using $records_found in event

12/14/2011 8:34:22 PM
PHPRunner General questions
W
weisd author

I am using the before SQL query even to log visitor searches in a table and want to add the number of records found.
I assume I have to insert into the particular field in the before display event?
My question is, how to collect that number? or, how to define, $records_found in the before display event?

C
cgphp 12/15/2011

In the "Before display" event enter this code:

global $conn;

$records_found = $xt->getvar("records_found");

db_exec("INSERT INTO log_table_name ('searches_field_name') VALUES (".$records_found.")",$conn);
W
weisd author 12/15/2011



In the "Before display" event enter this code:

global $conn;

$records_found = $xt->getvar("records_found");

db_exec("INSERT INTO log_table_name ('searches_field_name') VALUES (".$records_found.")",$conn);



That works! Thanks.
How can I insert into the record created in the Before SQL Query event?
In that event I do,
$strSQLInsert = "insert into Search_Queries (QueryField, DateField, IpAddress)

values ('".$Qry."','".$Number."','".$IpAddrss."')";

db_exec($strSQLInsert,$conn);
Adding your code to Before Display creates a new record. Does this all need to happen in the same event?

W
weisd author 12/15/2011



That works! Thanks.
How can I insert into the record created in the Before SQL Query event?
In that event I do,
$strSQLInsert = "insert into Search_Queries (QueryField, DateField, IpAddress)

values ('".$Qry."','".$Number."','".$IpAddrss."')";

db_exec($strSQLInsert,$conn);
Adding your code to Before Display creates a new record. Does this all need to happen in the same event?


Yep. Moved everything into the Before display event and that solved it.
$strSQLInsert = "insert into Search_Queries (QueryField, DateField, IpAddress, RecordsFound)

values ('".$crumbfeild."','".$Number."','".$IpAddrss."','".$records_found."')";

db_exec($strSQLInsert,$conn);