This topic is locked

save to another table from search

12/20/2009 3:41:59 AM
PHPRunner General questions
J
junior79 author

Ok this is probally really easy to do, unfortuantly the pills my doc has given me recently makes it hard to retain things for more than 5 minutes.
All i am looking to do is in the main list page when i do a search if the record exists in table a it copys it to table b.
Thanks

Junior

J
Jane 12/22/2009

Junior,
use List page: Before SQL query event for this purpose.

Here is just a sample:

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

{

$rstmp = CustomQuery($strSQL);

if ($datatmp = db_fetch_array($rstmp))

{

//save records in another table here

//...

}

}
J
junior79 author 12/22/2009

// List page: Before SQL query

function BeforeQueryList(&$strSQL,&$strWhereClause,&$strOrderBy)

{

global $conn,$strTableName,$where;

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

{

$rstmp = CustomQuery($strSQL);

if ($datatmp = db_fetch_array($rstmp))

{

$strSQLSave = "INSERT INTO located (barcode, description, location)

SELECT barcode, description, location FROM boxes WHERE $where";

db_exec($strSQLSave,$conn);

}

}

;

} // function BeforeQueryList
not throwing any errors but it wont copy anything into the located table either

I dunno I'm stuck again
and I'd like to say thank you to Jane once again for saving my butt

Thanks you very much
Junior

J
Jane 12/23/2009

Junior,
please see my changes below:

$strSQLSave = "INSERT INTO located (barcode, description, location) SELECT barcode, description, location FROM boxes WHERE ".$strWhereClause;
H
htwebdev 12/23/2009

Sweet, was just getting ready to research this very thing. Thanks.

J
junior79 author 12/23/2009

I hear ya htwebdev, I try for some hours before I give up then i post on here and Jane normally comes to the rescue.

But it's a good thing the more I am doing for this project the more I learn the faster i get things done and the happier they are.
Thanks Again
JUNIOR