Tengo un INSERT INTO que es para agregar 1 producto en varias categorias (3 para ser mas preciso). Si selecciono una opcion de cada 1 de los 3 se grava en la bd bien , pero si elijo solo 1 o 2 de los 3 , se gravan siempre los 3 aunque 2 lo hagan sin la categoria.
No se si soy lo suficientemente claro pero haver, aqui dejo la funcion INSERT, que viene de un form con 3 Listas posibles para selecionar (catId, catId2 y catId3).
function addProduct()
{
$catId = $_POST['cboCategory'];
$catId2 = $_POST['cboCategory2'];
$catId3 = $_POST['cboCategory3'];
$name = $_POST['txtName'];
$auteur = $_POST['txtAuteur'];
$editeur = $_POST['txtEditeur'];
$anne = $_POST['txtAnne'];
$lieu = $_POST['txtLieu'];
$ilustrateur = $_POST['txtIlustrateur'];
$reliure = $_POST['txtReliure'];
$format = $_POST['txtFormat'];
$key = $_POST['txtKey'];
$isbn = $_POST['txtIsbn'];
$ref = $_POST['txtRef'];
$etat = $_POST['txtEtat'];
$description = $_POST['mtxDescription'];
$price = str_replace(',', '', (double)$_POST['txtPrice']);
$qty = (int)$_POST['txtQty'];
$images = uploadProductImage('fleImage', SRV_ROOT . 'images/product/');
$mainImage = $images['image'];
$thumbnail = $images['thumbnail'];
$sql = "INSERT INTO tbl_product (cat_id, pd_titre, pd_auteur, pd_editeur, pd_anne_edition, pd_ilustrateur, pd_lieu, pd_keyword, pd_reliure, pd_format, pd_isbn, pd_ref, pd_etat, pd_descriptif, pd_price, pd_qty, pd_image, pd_thumbnail, pd_date)
VALUES ('$catId', '$name', '$auteur', '$editeur', '$anne', '$ilustrateur', '$lieu', '$key', '$reliure', '$format', '$isbn', '$ref', '$etat', '$description', $price, $qty, '$mainImage', '$thumbnail', NOW()),
('$catId2', '$name', '$auteur', '$editeur', '$anne', '$ilustrateur', '$lieu', '$key', '$reliure', '$format', '$isbn', '$ref', '$etat', '$description', $price, $qty, '$mainImage', '$thumbnail', NOW()),
('$catId3', '$name', '$auteur', '$editeur', '$anne', '$ilustrateur', '$lieu', '$key', '$reliure', '$format', '$isbn', '$ref', '$etat', '$description', $price, $qty, '$mainImage', '$thumbnail', NOW())";
$result = dbQuery($sql);
header("Location: index.php?catId=$catId");
}
A ver si ahora tengo contestaciones !!
Gracias de antemano
![de acuerdo](http://static.forosdelweb.com/fdwtheme/images/smilies/dedosarriba.png)