NECESITO ENVIAR UN ARREGLO QUE CONTIENE LOS ID DE UNA TABLA, Y UNA CANTIDAD QUE EL USUARIO TECLEE POR METODO POST, Y TAMBIEN UN CAMPO LLAMADO COSTO QUE SE ENCUENTRA EN UNA SOLA TABLA, HE LOGRADO ENVIAR EL ARREGLO PERO NO SE COMO RECIBIR LA CANTIDAD U OTRO VALOR, EL CODIGO QUE USO PARA ENVIAR EL ARREGLO Y LOS DEMAS CAMPOS ES EL SIG.
Código PHP:
<?php //Mostrar los registros
$enlace = mysql_connect ("mysql6.000webhost.com","a7657418_herb","herbolaria2011") or die("No se pudo conectar con el servidor");
mysql_select_db("a7657418_herb",$enlace) or die("No se pudo conectar con la base de datos"); //conexion con la bd
$sql= "SELECT Idcompuesto, nombre, costo_compuesto FROM compuestos_medicinales";
$result=mysql_query($sql, $enlace);
// Se inicial el formulario
echo "<form action=\"detcompuesto.php\" method=\"post\"> \n";
// Extraemos y componemos los checbox dinámicos de los datos de nuestra tabla de la BD.
while ($row = mysql_fetch_array($result)){
echo "<input type=\"checkbox\" name=\"seleccion[]\" value=\"".$row['Idcompuesto']."\">".$row['nombre']. "<br>";
echo "<input type=\"text\" name=\"cantidad\"> " ."<br>";
echo "<input type=\"hidden\" name=\"costo\" value=\"".$row['costo_compuesto']."\">" ."<br>";
}
//<input class="inputNormal" type="text" id="Nombre">
// Cerramos el formulario y ponemos nuestro botón de Submit.
echo "<input type=\"submit\" name=\"Submit\" value=\"Enviar\">";
echo "</form>";
?>
Y PARA RECIBIRLOS ENCONTRE ESTO, PERO NO SE COMO RECIBIR POR EJEMPLO LA CANTIDAD Y EL COSTO PORQUE NECESITO INSERTARLOS EN DETALLE_COMPUESTO DE LA CUAL LOS CAMPOS SELECCIONADOS Y ENVIADOS TIENE QUE IR AL MISMO ID, ES UNA RELACION MUCHOS A MUCHOS , LES PONGO EL CODIGO DONDE RECIBO LOS DATOS DEL ARREGLO, PERO NO SE COMO RECIBIR LOS OTROS DATOS PARA PODER INSERTARLOS, ESPERO NO SER MOLESTO Y MUCHAS GRACIAS DE ANTEMANO
OJALA ME HAYA DADO A ENTENDER,
Código PHP:
if($_POST['Submit'])
{
foreach($_POST['seleccion'] as $indice=>$valor )
{
mysql_query("INSERT INTO detalle_compuesto (id_compuesto) VALUES ($valor)");
}
}
?>