A
amirgulamali author
Hi I have 3 tables, one is primary and the other 2 are secondary, I am inserting entries in the secondary tables using the primary tables events and using if else etc Now I would like to move entries between my secondary tables, say maybe exchange entries or move to the other secondary table. I am trying to use events for the secondary tables but am running into errors all the time, I am using:
function BeforeEdit(&$values, $where)
{ // Parameters:
// $values - Array object.
// Each field on the Edit form represented as 'Field name'-'Field value' pair
// $where - string with WHERE clause pointing to record to be edited //********** Insert a record into another table ************
/*global $conn;
$strSQLInsert = "insert into TableName (Field1, Field2) values (Value1, Value2)";
db_exec($strSQLInsert,$conn); return true;
*/ global $conn,$strTableName; if ($values["course"] == "'1ee0'")
{ $strSQLInsert = "INSERT INTO _1ee0 (fname, lname, student_no, email) values ("; $strSQLInsert .= $values["fname"].",";
$strSQLInsert .= $values["lname"].",";
$strSQLInsert .= $values["student_no"].",";
$strSQLInsert .= $values["email"]; $strSQLInsert .= ")";
db_exec($strSQLInsert,$conn); return true; // return true if you like to proceed with adding new record
// return false in other case }
else if ($values["course"] == "'2ee0'")
{ $strSQLInsert = "INSERT INTO _2ee0 (fname, lname, student_no, email) values ("; $strSQLInsert .= $values["fname"].",";
$strSQLInsert .= $values["lname"].",";
$strSQLInsert .= $values["student_no"].",";
$strSQLInsert .= $values["email"]; $strSQInsert .= ")";
db_exec($strSQLInsert,$conn); return true; } else
echo "no table specified";
// return true if you like to proceed with editing this record
// return false in other case
} and am also trying using:
function AfterEdit(&$values)
{
//********** Insert a record into another table ************
global $conn; $strSQLInsert = "INSERT INTO _1ee0 (fname, lname, student_no, email) values ("; $strSQLInsert .= $values["fname"].",";
$strSQLInsert .= $values["lname"].",";
$strSQLInsert .= $values["student_no"].",";
$strSQLInsert .= $values["email"]; $strSQLInsert .= ")";
db_exec($strSQLInsert,$conn); return true; } I am running into errors; _1ee0 and _2ee0 are the 2 secondary tables. Pls advice
|
|