Hello,
I created a button that inserts data into another table and it works great. I have this button on the list page. Is there a way to have this button check to see if a record exists in that other table before it inserts data?
This is the code I have for inserting data into another table in the "Server" tab of the button:
global $dal;
if($keys['ID'])
{
$tblEvents = $dal->Table("Other_Table");
$tblEvents->Value["ID2"]=$keys["ID"];
$tblEvents->Value["PID"]=$_SESSION["UserID"];
$tblEvents->Value["person_like"]=1;
$tblEvents->Add()
}
Is it possible to use something like this?
global $conn;
$strSQLExists = "SELECT ID, PID FROM Other_Table WHERE PID = ".$_SESSION["UserID"]." AND ID2 = ".$keys["ID"]."";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
pop-up stating that this record already exists.
}
else
{
dal code from above
}
Thanks for any help,
Brian