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

$art_id = $_POST['art_id'];
$cott_id = $_POST['cott_id'];
$number = count($_POST["sabor"]); 
$sql=mysqli_query($con,"DELETE FROM cotizacion_sabores_producto_temp WHERE usuario='$usu_id' and cott_id='$cott_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_productos 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_producto_temp (sab_id,sab_nombre,art_id,usuario,cott_id) VALUES ('$dato1','$sab_nombre','$art_id','$usu_id','$cott_id')") or die(mysqli_error($con));
        }
    }
}           
?>