Ver Mensaje Individual
  #22 (permalink)  
Antiguo 11/11/2009, 07:32
ingluis
 
Fecha de Ingreso: enero-2009
Mensajes: 197
Antigüedad: 15 años, 3 meses
Puntos: 0
Información Respuesta: como puedo hacer insert a dos tablas diferentes

Que pena con usted david no pude con ese error, anexo mejor todo el codigo del archivo, donde va el mismo codigo el formulario con el insert:

<html>
<link href="estilo.css" rel="stylesheet" type="text/css">
<?php
include_once("funciones.php");
$fecha = $_POST['fecha'];
$horaini = $_POST['horaini'];
$horafin = $_POST['horafin'];
$sala = $_POST['sala'];
$vbeam = $_POST['vbeam'];
$responsable = $_POST['responsable'];
$evento = $_POST['evento'];
if($fecha != "" && $horaini != "" && $horafin != "" && $sala != "" && $responsable != "" && $evento != "")
{
$conexion = conectar();
$vbeam = isset($_POST['vbeam'])? 1: 0; // estado del check, envia 1 si necesita o 0 si no
if ($_POST['sala'] == "Gerencia")
{
/*echo 'verdadero';
}
else
{
echo 'Falso';
}*/

/*$sql = "insert into neiva(fecha,horaini,horafin,sala,videobeam,respons able,evento) values('$fecha','$horaini','$horafin','$sala','$vb eam','$responsable','$evento')";
$sql2 = "insert into bogota(fecha,horaini,horafin,sala,videobeam,respon sable,evento) values('$fecha','$horaini','$horafin','Sala Grande(14P)--1701','$vbeam','$responsable','$evento')";*/

$sql = "insert into neiva(fecha,horaini,horafin,sala,videobeam ,responsable,evento) values('$fecha','$horaini','$horafin','$sala', '$vbeam','$responsable','$evento'); insert into bogota(fecha,horaini,horafin,sala,videobea m,responsable,evento) values('$fecha','$horaini','$horafin','Sala Grande(14P)--1701','$vbeam','$responsable','$evento')";
$res = mysql_query($sql,$conexion);
}
else
{
$res = false;
}
//}
/*$res = mysql_query($sql,$conexion)or die( mysql_error() );
$res = mysql_query($sql2,$conexion)or die( mysql_error() );*/
if($res)
{
echo "Evento grabado";
redireccionar('3','mostrar.php');
}
else
{
echo "Error al grabar evento";
}
desconectar($conexion);
}
else
{
?>
<style type="text/css">
<!--
.Estilo20 { font-size: 9px;
font-weight: bold;
}
.Estilo21 {
color: #CC0000;
font-weight: bold;
font-style: italic;
}
-->
</style>
<form action="agregar.php" method="post" name="f1">
<table border=0 cellspacing="0">
<tr><td colspan="2"><span class="Estilo21">[AGREGAR EVENTO]</span></td></tr>
<tr><td>Fecha</td><td><input type="text" name="fecha" value="<?php echo date('Y-m-d'); ?>" />
Por favor respete el formato </td>
</tr>
<tr><td valign="TOP"><div align="left">
<p>Hora Inicio </p>
<p>Hora Final </p>
</div></td><td><p>
<input name="horaini" type="text" value="HH:MM:SS" />
</p>
<p>
<input name="horafin" type="text" value="HH:MM:SS" />
</p></td></tr>
<tr><td align="center"><div align="left">Sala</div></td>
<td align="center"><div align="left"><span class="Estilo20">
<select name="sala">
<option>--Seleccione--</option>
<option value="Contabilidad">Contabilidad</option>
<option value="Recursos Humanos">Recursos Humanos</option>
<option value="Auditorio">Auditorio</option>
<option value="Gerencia">Gerencia</option>
<option value="Ninguna">Ninguna</option>
</select>
</span></div></td>
</tr>
<tr>
<td align="center"><div align="left">Video Beam
</div></td>
<td align="center"><div align="left">
<input type="checkbox" name="vbeam" value="vbeam">
</div></td>
</tr>
<tr>
<td align="center"><div align="left">Responsable
</div></td>
<td align="center"><div align="left">
<input name="responsable" type="text" size="40" maxlength="40" />
</div></td>
</tr>
<tr>
<td align="center">Observaciones</td>
<td align="center"><div align="left">
<textarea rows="5" cols="20" name="evento"></textarea>
</div></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="Enviar" /></td>
</tr>
</table>
</form>
<?
}
?>
</html>