formulario de ingreso :
Código PHP:
<form action="carga_op.php" method="post" name="form1" class="seccion" id="form1">
<div class="descripccionSeccion">
<table width="340" align="center" class="oSuperior">
<!--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>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"><label>Trabajador:</label></td>
<td><?php cargar_combo("tblempleados","Id_Empleado","Apellido"); ?></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="oBoton" id="Submit" value="Cargar OP >>" /></td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
</form>
y este es el que graba los datos en la tabla:
Código PHP:
<?php
//include ("../jao/conexion.php");
$enlace = mysql_connect("localhost", "root", "") or die("No pudo conectarse : " . mysql_error());
mysql_select_db("name") or die("No pudo seleccionarse la BD.");
$cliente=$_POST['tblclientes'];
$fechaFormat=$_POST['FechaInicio'];
$fecha=cambiaf_a_mysql($fechaFormat);
$operario=$_POST['tblempleados'];
$Turno=$_POST['tbltipoturno'];
$Numero=$_POST['Numero'];
$insert="insert into tbl_op (Fecha, id_Cliente, Id_Empleado, id_TipoTurno) values ('".$fecha."',".$cliente.",".$operario.",".$Turno.")";
$resIns=mysql_query($insert);
$idop=mysql_insert_id();
/*echo"<script>alert(\"$cliente\")</script>";*/
$sql = "SELECT * FROM tblproducto WHERE id_cliente='".$cliente."'";
/*echo"<script>alert(\"$sql\")</script>";*/
$resSql=mysql_query($sql);
$numProductos=mysql_num_rows($resSql);
//para el cliente
$sqlC = "SELECT * FROM tblempleados WHERE Id_Empleado='".$operario."'";
/*echo"<script>alert(\"$sqlC\")</script>";*/
$resSqlC=mysql_query($sqlC);
$rowClient=mysql_fetch_array($resSqlC);
//para el N de Guiass
$sqlA = "SELECT * FROM tbl_op WHERE id_op='".$idop."'";
/*echo"<script>alert(\"$sqlA\")</script>";*/
$resSqlA=mysql_query($sqlA);
$rowGuias=mysql_fetch_array($resSqlA);
//para el cliente
$sqlo = "SELECT * FROM tblclientes WHERE id_Cliente='".$cliente."'";
/*echo"<script>alert(\"$sqlC\")</script>";*/
$resSqlo=mysql_query($sqlo);
$rowCliente=mysql_fetch_array($resSqlo);
?>