<?php
session_start();
require_once('../conexion.php');
include "../include/sesiones.php";

$combo_id = $_POST['combo_id'];
$cdc_id = $_POST['cdc_id'];

$number = count($_POST["sabor"]); 
$sql=mysqli_query($con,"DELETE FROM cotizacion_sabores_combo_temp WHERE usuario='$usu_id' and cdc_id='$cdc_id'") or  die(mysqli_error($con));
if($number > 0)  
{ 
    for($i=0; $i<$number; $i++)  
    {  
       	if(trim($_POST["sabor"][$i] != '') )
		{
		    $dato1=$_POST["sabor"][$i]; 

		    $can2=mysqli_query($con,"SELECT * from sabores_combos where sab_id='$dato1'") or die(mysqli_error($con)); 
		    $row=mysqli_fetch_array($can2);
		    $sab_nombre=$row["sab_nombre"];  
      	
			$regis=mysqli_query($con,"INSERT INTO cotizacion_sabores_combo_temp (sab_id,sab_nombre,com_id,usuario,cdc_id) VALUES ('$dato1','$sab_nombre','$combo_id','$usu_id','$cdc_id')") or die(mysqli_error($con));
		}
  	}
}			
?>