Im struggling with trying to sort out Enter info in new table on the edit field..
I'm using the following code:
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
//********** Check if specific record exists ************
global $conn;
$strSQLExists = "select * from _To where Info='Info'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
// if record exists do something
// if dont exist do something else
//********** Display a message on the Web page ************
echo "Sorry, record exists";
}
else
{
// if dont exist do something else
//********** Display a message on the Web page ************
echo "Thanks for adding you're info";
}
return true;
// return true if you like to proceed with editing this record
// return false in other case
}
It always returns the message Thank you..., even if the record exists in the _To table. What's wrong.
My end task is the following:
I want to select the edit from the _From table. When saving the changes (will eventually change the link to "Enter for tournament" and make all fields readonly. Once the user selects enter tfor this tournament, the info should be submitted to the new table (for testing purposes called _To table). I can get this right, but except that when the field exists already, it must give a message "You entered for this tournament already"
I tried the following, but it does not work as it should:
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
//********** Check if specific record exists ************
global $conn;
$strSQLExists = "select * from _To where PlayID='PlayID'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
// if record exists do something
//********** Display a message on the Web page ************
echo "You entered already!";
}
else
{
// if dont exist do something else
//********** Insert a record into another table ************
global $conn;
$strSQLInsert = "insert into _To (PlayID, Info) values (PlayID, Info)";
db_exec($strSQLInsert,$conn);
}
return true;
// return true if you like to proceed with editing this record
// return false in other case
Will appreciate some help!