I have two tables with a 1…n relationship. 1 value in table 1 can have n values in table 2. How can i delete only the value from table 2 when a user clicks on delete button (after he selected the row in grid) in grid and there are more then 1 value in table 2? It’s important that only the values (the row) from table 2 will be deleted but not not from table 1! On the other side if there is only 1 entry in both tables (1 to 1 relationship) both rows have to been deleted.
I use dhtmxconnector and php/mysql. I’ve tried it with beforeDelete event but it didn’t work. Here is my code:
[code]}
function deleteTest($action)
{
$host = ‘localhost’;
$user = ‘root’;
$pw = ‘test1234’;
$db = ‘LogTranslation’;
$mysqli = new mysqli($host, $user, $pw, $db);
$sql = "SELECT LogCallID FROM SYS_LogCallDescription ";
$result = $mysqli->query($sql);
if($mysqli->affected_rows > 1)
{
$sql2 = "DELETE FROM SYS_LogCallDescription WHERE SYS_LogCallDescription.LogCallID = '{LogCallID}' AND LcdID = '{LcdID}'";
$mysqli->query($sql2);
}
$result->close();
}
$grid->event->attach(“beforeDelete”, deleteTest);
[/code]