<?php
include("top.php");
$mode=$_POST['mode'];
	if($mode == 'packchange_insert')
	{
	
		$price = trim($_POST['ptotal']);
		$pay_ch = trim($_POST['pacl']);
		$packpr = trim($_POST['ptotal']);
		$userid = trim($_POST['rowid']);
		$mcf = trim($_POST['ncff']);
		$pac_id = trim($_POST['pacid']);
		$query="UPDATE adduser SET price='$price',pay_ch='$pay_ch',packpr='$packpr',ncf='$mcf'  WHERE id='$userid'";
		
			$ins=mysqli_query($con,$query);
			if($ins){
				$p=explode(',',$pac_id);
				$k=count($p);
				for ($i=0; $i <$k ; $i++) { 
			    $a=$p[$i];
				$sql=mysqli_query($con,"INSERT INTO `tbl_package_details` SET customer_id='$userid',pac_id='$a',cust_date=CURDATE(),status='0'");
				// echo "INSERT INTO `tbl_package_details` SET customer_id='$userid',pac_id='$a',cust_date=CURDATE(),status='0'";
				}
				echo 'Saved';
			}
		}
	
	?>