Este es el formularo de ingreso
Código PHP:
<?php
session_start();
?>
<html>
<head>
<script language='javascript' src="../Funciones/popcalendar.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../css/estructura.css" rel="stylesheet" type="text/css">
<link href="../css/tour.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
//include ("../jao/Conexion.inc.php");
$enlace = mysql_connect("localhost", "root", "") or die("No pudo conectarse : " . mysql_error());
mysql_select_db("name") or die("No pudo seleccionarse la BD :(.");
$_SESSION['numProductos']=1;
function cargar_combo($tabla,$value,$opt)
{
$sql = "select * from ".$tabla;
$res = mysql_query($sql) or die (mysql_error());
echo '<select name="'.$tabla.'" id="'.$tabla.'" class="botones">';
while($fila = mysql_fetch_assoc($res))
{
echo "<option value='".$fila[$value]."'>$fila[$opt]</option>";
}
echo "</select>";
}
?>
<div id="nonfooter">
</div>
<div class="tabs"> Ingreso Producciones</div>
<form action="carga_op.php" method="post" name="form1" class="seccion" id="form1">
<div class="contenido">
<table width="0%" align="left" class="titblok">
<!--DWLayoutTable-->
<tr>
<td width="115" height="21">
<label></label>
Cliente:</td>
<td width="141"><?php cargar_combo("tblclientes","id_Cliente","Nombre","Activo"); ?></td>
<td colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="122"> </td>
</tr>
<tr>
<td height="21"><label>Trabajador:</label></td>
<td><?php cargar_combo("tblempleados","Id_Empleado","Apellido","Jose"); ?></td>
<td colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td> </td>
</tr>
<tr>
<td height="24"><label>Fecha: </label></td>
<td> <input name="FechaInicio" type="text" class="campos_guia" id="FechaInicio" onClick="popUpCalendar(this, form1.FechaInicio, 'dd-mm-yyyy');" size="10" /> </td>
<td colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td> </td>
</tr>
<tr>
<td height="24">Turno: </td>
<td valign="top"><label for="textfield">
<?php cargar_combo("tbltipoturno","id_TipoTurno","Nombre"); ?>
</label></td>
<td colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td> </td>
</tr>
<tr>
<td height="28"> </td>
<td> </td>
<td width="1"> </td>
<td width="114" valign="top"><input name="Submit" type="submit" class="button4" id="Submit" value="Cargar OP >>" /></td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
</form>
<p>
</table>
</body>
</html>
este es el que inserta los productos
Código PHP:
<?php
$enlace = mysql_connect("localhost", "root", "") or die("No pudo conectarse : " . mysql_error());
mysql_select_db("name") or die("No pudo seleccionarse la BD.");
$id_op=$_POST['id_op'];
foreach($_POST as $key => $valor)
{
list($constante, $numField)=split("_", trim($key));
if($constante=="categoria")
{
$cat[$numField]=$valor;
}
if($constante=="cantidad")
{
$can[$numField]=$valor;
}
if($constante=="producto")
{
$prod[$numField]=$valor;
}
}
foreach($cat as $key => $valor)
echo "<script>alert(\"$valor\")</script>";
{
$Ssql="insert into tblproducciones(categoria, id_op, Cantidad, id_Produccion) values (";
$Ssql.=$valor.", ".$id_op.", ".$can[$key].", ".$prod[$key].")";
echo "<script>alert(\"$Ssql\")</script>";
$resIns=mysql_query($Ssql);
}
echo '<head><meta http-equiv="refresh" content="0; url=ingreso_op.php"></head>';
?>