Foros del Web » Programando para Internet » PHP »

agregar datos al mismo tiempo (en 2 tablas diferentes)

Estas en el tema de agregar datos al mismo tiempo (en 2 tablas diferentes) en el foro de PHP en Foros del Web. Hola,estoy aprendiendo PHP esto es lo que necesito:(tengo 2 tablas: MATERIAL e INVENTARIO) Seleccionar el TIPO_MATERIAL, agregarlo al INVENTARIO si fue una compra el problema ...
  #1 (permalink)  
Antiguo 02/04/2004, 10:06
 
Fecha de Ingreso: abril-2004
Ubicación: Aguascalientes
Mensajes: 65
Antigüedad: 20 años
Puntos: 0
agregar datos al mismo tiempo (en 2 tablas diferentes)

Hola,estoy aprendiendo PHP
esto es lo que necesito:(tengo 2 tablas: MATERIAL e INVENTARIO)
Seleccionar el TIPO_MATERIAL, agregarlo al INVENTARIO si fue una compra
el problema es que solo se agrega a una sola tabla (INVENTARIO)y quiero que se
agregue tambièn a MATERIAL tengo 2 archivos:

AGREGA_MATERIAL.PHP

$tipo_mat=$_POST['Cmbtipo_mat'];
$descrip=$_POST['Eddescrip'];
if($tipo_mat=="compra")

{
include ('conexion.php');
$sql = "insert into inventario (tipo_material,descripcion)values('$tipo_mat','$de scrip')";
$consulta=mysql_query($sql,$conexion) OR die("No se pudò insertar TIPO DE MATERIAL a INVENTARIO"); //realizo la consulta
echo "<script language='javascript'>";
echo "window.alert('Se agregò el material comprado $descrip.');"; //mando mensaje
echo "</script>";
}
?>

TIPO_MATERIAL.HTML

<html>
<head>
<title>Untitled</title>
</head>
<body bgcolor=#cccccc>
<form action="agrega_material.php" method="POST">
<div align=""center >
<h3><b><center>TIPO DE MATERIAL de la escuela</center></b></h3>
<table border=1 align="center">
<tr><td align="right"><b>Tipo de Material</b>
<select name="Cmbtipo_mat">
<option>compra
<option>asignaciòn de un consumible
<option>bien duradero
</select><br><p></p>
<tr><td align="center"><b>Descripciòn</b><input type="text" name="Eddescrip"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" value="Guardar datos"></td></tr>
</body>
</html>

Espero su respuesta, gracias...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:22.