Adding / Deleting related data to another table
Adding / Deleting related data to another table
When I create a new entry in my table, using editor, the ajax page uses the row id for the newly inserted row and appends rows into a related table.
the ajax pseudocode is like this
if ( isset($_POST['action']) && $_POST['action'] === 'create' ) {
//append appropriate rows into table for this newentry
$sql = $db->sql( "INSERT INTO tablename ( Fields )
WHERE value = ".$rowid."");
}
this works fine.
If an entry is removed, i want to do a similar thing, with a delete.
I tried this
but nothing is triggered
if ( isset($_POST['action']) && $_POST['action'] === 'remove' ) {
//delete appropriate rows from table for this deleted entry
$sql = $db->sql( "DELETE FROM tablename WHERE value = ".$rowid."");
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
What you have got looks correct to me. Do you get any errors or anything else to indicate what might be going wrong? If not, then you might need to add a bit of debug trace code to see what is going on.
Allan
Ah, good to know I was at least on the right track.
Found the problem, i was trying to use 'data' to retrieve the row id
On re-reading http://editor.datatables.net/manual/server I found I needed to use 'id'
So I imploded the returned array, and it works !
;-)