Delete is a little tricky, two variables needed. One is the existing $eduIdDb obtained from database, second is during POST($eduIDpost) to find out which row is being removed. Hence a function array_diff() is being used.
//Getting eduIDpost from the POST $eduIDpost = $_POST['spprofile']['eduID']; //Getting the eduIdDb from the database when first loading the form $testquery = "SELECT * FROM education WHERE member_Member_id = '$memberid_esc'"; $resultTestQuery = $db->readQuery($testquery); if (isset($resultTestQuery)){ //echo '<pre>', print_r($resultTestQuery, true), '</pre>'; foreach ($resultTestQuery as $result){ $eduIdDb[] = $result['Education_id']; } } //Find out the deleted Rows $deleted_rows = array_diff($eduIdDb, $eduIDpost); //Delete the removed rows from database foreach ($deleted_rows as $rowdelete){ $rowdelete_esc = $db->mysql_escape($rowdelete); $query = "DELETE FROM education WHERE Education_id='$rowdelete_esc'"; $queryDelete = $db->writeQuery($query); if (!empty($queryDelete)){ $database_mod = TRUE; //echo "Successfully deleted entries."; } }