This topic is locked

Last Search

6/24/2010 2:48:40 PM
PHPRunner General questions
J
joker author

I have read a couple of old posts on this subject but I am using PHPRunner 5.2 and I cannot reply to locked threads.
Basically, I would like to save the last user search to a user table. Each time a user logs in, it defaults to their own last sql search. If the user hits "show all" it saves that to the table as the last search.
I know I need to include this as an event on the search page. I just don't know the variable names I need to acquire or the way I need to word that on my event.
If it would be easier to do it another way, please let me know.
Any suggestions are appreciated!
Thanks!

A
ann 6/25/2010

Hi,
use the following code to save search parameters

http://www.asprunner.com/forums/topic/14570-how-to-print-search-parameters-on-the-list-page/
You need to add code which will save $fName, $val1 variables into the table fields. Here is a sample:

global $conn;

$strSQLInsert = "insert into TableName (Field1, Field2) values ('".$fNameValue1."',".$val1.")";

db_exec($strSQLInsert,$conn);



where TableName is your actual table name, Field1, Field2 your actual field names.

J
joker author 6/25/2010



Hi,
use the following code to save search parameters

http://www.asprunner.com/forums/topic/14570-how-to-print-search-parameters-on-the-list-page/
You need to add code which will save $fName, $val1 variables into the table fields. Here is a sample:

global $conn;

$strSQLInsert = "insert into TableName (Field1, Field2) values ('".$fNameValue1."',".$val1.")";

db_exec($strSQLInsert,$conn);



where TableName is your actual table name, Field1, Field2 your actual field names.



Ann,
I set List page: Before display event to save search parameters like the page suggested. Where do I put your code? Is it php code snippet?
Thank you so much for your help!

J
Jane 6/28/2010

Hi,
add your code in the List page: Before display event.

If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

J
joker author 7/1/2010



Hi,
add your code in the List page: Before display event.

If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.


Hi,
I don't really have an error to reproduce, I'm building this as we go.
So I put both sets of code (yours and the code from the page which details how to print search parameters) on the List page: Before display.
How would I go about getting these values from the table and passing that to the SQL when the user logs in?
Any comments are welcome

A
ann 7/2/2010

Hi,
modify code in the following way:

global $conn;

$strSQLInsert = "insert into TableName (Field1, Field2, Field3, Field4) values ('".$fNameValue1."','".$val1."',now(),'".$_Session["UserID"]."')";

db_exec($strSQLInsert,$conn);



then use List page: Before SQL query event to set up previous search fields as default. Here is a sample:

$rstmp=CustomQuery("select Field1, Field2 from TableName where Field4='".$_Session["UserID"]."' order by Field3 desc")

if ($datatmp=db_fetch_array($rstmp)){

$custom_where=$datatmp["Field1"]."='".$datatmp["Field2"]."'";

}

if ($custom_where && $_Session["MainTableName_advsearch"])

$strWhereClause=whereAdd($strWhereClause,$custom_where);