Estoy realizando una consulta a la bd, esta consulta la llamo a un formulario, esta consulta es de mi tabla de separaciones, esto quiere decir que si el cliente hace varias separaciones, logicamente apareceran en diferentes filas de la tabla, pero con los mismos nombres de campo de texto, he aqui el codigo.
Código PHP:
<?php
$documento=$_REQUEST['documento'];
include 'db.php';
$link=conectarse();
$result=mysql_query("select documento,nombre,telefono,email,producto,unidadmed,cantidad,valor,fecha,hora,total,referencia FROM separacion WHERE documento='$documento'",$link);
if($row=mysql_fetch_array($result))
{
echo "<br>";
echo "<form action='procesa_venta.php' method='post'><table width='550'>";
echo "<tr><td><b><center>FECHA SEPARACIÃ’N</td><td><b><center>DOCUMENTO</td><td><b><center>NOMBRE</td><td><b><center>PRODUCTO</td><td><b><center>UNIDAD MEDIDA</td><td><center><b>Nº</CENTER></td><td><b><center>VALOR</td></tr></b>";
do{
$f=date("Y-m-d ");
$h=date("G:i:s");
list($hora1, $minut) = split('[:]', $h);
$h=date("G:i:s", mktime($hora1-1, $minut, 0));
$total=($row["valor"])*($row["cantidad"]);
$doc=$row["documento"];
echo "<tr>
<input type='hidden' size='12' value='".$row["referencia"]."' name='referencia' readonly ></td>
<td><input type='text' size='17' value='".$row["hora"]." / ".$row["fecha"]."'name='a' readonly >
<td><input type='text' size='12' value='".$row["documento"]."' name='documento' readonly ></td>
<td><input type='text' size='30' value='".$row["nombre"]."' name='nombre' readonly ></td>
<td><input type='text' size='25' value='".$row["producto"]."'name='producto' readonly ></td>
<td><input type='text' size='8' value='".$row["unidadmed"]."'name='unidadmed' readonly ></td>
<td><input type='text' size='3' value='".$row["cantidad"]."' name='cantidad' readonly ></td>
<td><input type='text' size='7' value='".$row["total"]."' name='valor' readonly >
<input type='hidden' size='7' value='$f' name='f' readonly >
<input type='hidden' size='7' value='$h' name='h' readonly >
</td></tr>";}
while($row=mysql_fetch_array($result));
echo "<center><br>
";
}
else{echo"<br>";
echo "<center><i><b><h2>En este momento no tenemos unidades disponibles";}
?>
<?php
Código PHP:
<?php
$referencia=$_REQUEST['referencia'];
$producto=$_REQUEST['producto'];
$cantidad=$_REQUEST['cantidad'];
$unidadmed=$_REQUEST['unidadmed'];
$valor=$_REQUEST['valor'];
$documento=$_REQUEST['documento'];
$nombre=$_REQUEST['nombre'];
$cantidadtotal=$_REQUEST['cantidadtotal'];
$valortotal=$_REQUEST['v'];
$fecha=$_REQUEST['f'];
$hora=$_REQUEST['h'];
include 'db.php';
$link=conectarse();
if($hora==$documento) {
do {
if($producto==$valor){
echo "<br><br><center> <h1><i>Venta ya registrada...</h1></i>";
$no=1;}
}
while ($row=mysql_fetch_array($result));
}
if($no==0){
$sql="INSERT INTO venta(referencia,producto,unidadmed,cantidad,valor,documento,nombre,cantidadtotal,valortotal,fecha,hora) VALUES ('$referencia','$producto','$unidadmed','$cantidad', '$valor','$documento','$nombre','$cantidadtotal','$valortotal','$fecha','$hora')";
$result=mysql_query($sql,$link);
if($result){
echo "<center>";
echo "<br><br> <h1><i>Venta realizada exitosamente...</h1></i>\n";}
else {echo "<br><br><br><h2><i><center>problemas!!!!!</h2>";
}
}
?>
<?php
$producto=$_REQUEST['producto'];
$result=mysql_query("select * FROM separacion WHERE producto='$producto' nombre='$nombre'",$link);
if($producto)
{
$sql="UPDATE usuarios SET cod= cod + 1 WHERE documento='$documento'";
$result=mysql_query($sql, $link);
$sql="DELETE FROM separacion WHERE producto='$producto' and nombre='$nombre'";
$result=mysql_query($sql,$link);
}
?>
De antemano les agradezco la ayuda...