Hi.. I am modifying the function BeforeAdd(&$values) so that data is entered into different tables depending on the "course" selection (either 1ee0 or 2ee0)
this is the original function: (which works just fine)
function BeforeAdd(&$values)
{
// Parameters:
// $values - Array object.
// Each field on the Add form represented as 'Field name'-'Field value' pair
//********** Save new data in another table ************
global $conn,$strTableName;
$strSQLSave = "INSERT INTO _1ee0 (fname, lname, student_no, email) values (";
$strSQLSave .= $values["fname"].",";
$strSQLSave .= $values["lname"].",";
$strSQLSave .= $values["student_no"].",";
$strSQLSave .= $values["email"];
$strSQLSave .= ")";
db_exec($strSQLSave,$conn);
return true;
// return true if you like to proceed with adding new record
// return false in other case
}
However when I modify this code by adding an if else condition, data is always entered into 2ee0 (the ELSE condition).. the IF condition always fails even if I select the course as 1ee0.. this is my final code page:
<?php
function BeforeAdd(&$values)
{
// Parameters:
// $values - Array object.
// Each field on the Add form represented as 'Field name'-'Field value' pair
//********** Save new data in another table ************
global $conn,$strTableName;
if($values["course"] == '1ee0')
//if($_POST["course"]=="1ee0")
//if ("course" == "1ee0")
{
$strSQLSave = "INSERT INTO _1ee0 (fname, lname, student_no, email) values (";
$strSQLSave .= $values["fname"].",";
$strSQLSave .= $values["lname"].",";
$strSQLSave .= $values["student_no"].",";
$strSQLSave .= $values["email"];
$strSQLSave .= ")";
db_exec($strSQLSave,$conn);
}
else {
$strSQLSave = "INSERT INTO _2ee0 (fname, lname, student_no, email) values (";
$strSQLSave .= $values["fname"].",";
$strSQLSave .= $values["lname"].",";
$strSQLSave .= $values["student_no"].",";
$strSQLSave .= $values["email"];
$strSQLSave .= ")";
db_exec($strSQLSave,$conn);
}
return true;
// return true if you like to proceed with adding new record
// return false in other case
}
?>
Can anybody point out what im missing? is something wrong with the IF condition?
if($values["course"] == '1ee0')
or anything else?
thanx
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=3032&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />