alguien podría por favor de darme una manito.
por cierto menos me funciona la suma
![triste](http://static.forosdelweb.com/fdwtheme/images/smilies/frown.png)
Cannot add or update a child row: a foreign key constraint fails (`DB_demo`.`sales`, CONSTRAINT `SK` FOREIGN KEY (`id_product`) REFERENCES `product` (`id_product`) ON DELETE CASCADE ON UPDATE CASCADE)
Código PHP:
Ver original
<?php //add.php include_once 'conn.php'; { $cantidad = $_POST['cantidad']; $precio = $_POST['precio']; $eltotal = $_POST['eltotal']; // $ganancia = $eltotal - $cantidad * $precio; // ESTO NO ME FUNCIONA $sql = "INSERT INTO sales (cantidad,precio,eltotal,ganancia) VALUES ('$cantidad','$precio','$eltotal','$ganancia')"; echo "ok... "; } else { } } ?> <form method="post" action="add.php"> <input type="text" name="cantidad" > <input type="text" name="precio" > <input type="text" name="eltotal" > <button type="submit" name="addsale">enviar</button> </form>