The main issue facing your code seems to be a misunderstanding of how flow control works. The approach you have taken is to attempt to use the if / else / endif to construct how you want your code to look instead of what you want your code to do.
Your procedure is to use a loop if $_GET['delete_all'] is present as an array, and to otherwise use $_GET['delete_id']. So first check the contents of the variables and then take the appropriate action. The whole thing can be simplified by placing $_GET['delete_id'] into an array if $_GET['delete_all'] isn't there.
// Empty array we'll fill later
$delete_ids = array();
// If the delete_all array is available, use it as the array to delete from
if (isset($_GET['delete_all']) && is_array($_GET['delete_all'])) {
$delete_ids = $_GET['delete_all'];
}
// Next if delete_id is present
else if (isset($_GET['delete_id'])) {
// Place it into the array to use later
$delete_ids[] = $_GET['delete_id'];
}
else {
// Neither was set, you have an error state, so handle it however you need to
// Redirect, display an error, whatever.
}
// Now loop over your array and perform the action.
// The array either contains the original array from $_GET['delete_all'] or the single element $_GET['delete_id']
// Or it may be empty entirely, and therefore won't do anything
foreach ($delete_ids as $delete_id) {
$this->db_delete('ma_port', array('id' => $delete_id));
}
// And finish with your redirect
redirect($url);
foreach():. The alternate flow control syntax (using theif/endif foreach/endforeachis not recommended outside of HTML templating. Use proper bracketed control structures and this stuff becomes easy to spot.if () {...} else {...}andforeach() {... }