<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/Basic.php');
$orig_course_section_id =  $_POST['from'];
$del_merge_id = $_POST['what'];

$ms_cur = db_request(db_execute("SELECT MERGE_ID,COURSE_SECTION_ID,COURSE_ID FROM COURSE_SECTIONS WHERE COURSE_SECTION_ID = '".$orig_course_section_id."'"));
$merge_id = $ms_cur[1]['MERGE_ID'];
$merge_array = explode(",",$merge_id);
unset($dml);
foreach($merge_array as $ind=>$merge_id)
{
	if($merge_id != $del_merge_id)
		$dml .= $merge_id.',';
}
$dml = substr($dml,0,strlen($dml)-1);
if(db_execute("UPDATE COURSE_SECTIONS SET MERGE_ID='".$dml."' WHERE COURSE_SECTION_ID='".$orig_course_section_id."'"))
    echo _("Delete sucsesseful");
else
    echo _("Error");

?>