Ver Mensaje Individual
  #11 (permalink)  
Antiguo 10/07/2014, 10:34
Avatar de Jlopez2014
Jlopez2014
 
Fecha de Ingreso: julio-2014
Ubicación: Barranquilla
Mensajes: 154
Antigüedad: 9 años, 9 meses
Puntos: 0
Respuesta: Resource id #5

Cita:
<? include("seguridad.php"); ?>

<?php
include("conexion.php");
?>

<!DOCTYPE html>
<html>
<head>
<title>Pedidos</title>
</head>


<body>
<header>
<h2><center>INGRESO DE PEDIDOS</center></h2>
</header>
<div id="leo">
<section id="leon">

<section id="leone">


<a href="logout.php">Cerrar sesi&oacute;n</a>

<br><a href="compras.php">Regresar</a></br>


<?php
$var="";
$var1="";
$var2="";
$var3="";



if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
$bus=$_POST["txtbus"];
if($btn=="Buscar"){

$sql="select * from contenidopedido where nopedido='$bus'";
$cs=mysql_query($sql,$cn);
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];



}


}

if($btn=="Agregar"){
$nopedido=$_POST["txtnopedido"];
$nopro=$_POST["txtnopro"];
$cantidad=$_POST["txtcantidad"];
$obs=$_POST["txtobs"];



$sql="insert into contenidopedido values ('$nopedido','$nopro','$cantidad','$obs')";

$cs=mysql_query($sql,$cn);
echo "<script> alert('Se inserto correctamente el pedido');</script>";


}

if($btn=="Actualizar"){
$nopedido=$_POST["txtnopedido"];
$nopro=$_POST["txtnopro"];
$cantidad=$_POST["txtcantidad"];
$obs=$_POST["txtobs"];


$sql="update contenidopedido set idproducto='$nopro',cantidad='$cantidad',observaci ones='$obs'where nopedido='$nopedido'";

$cs=mysql_query($sql,$cn);
echo "<script> alert('Se actualizo correctamente el pedido');</script>";
}

if($btn=="Eliminar"){
$nopedido=$_POST["txtnopedido"];

$sql="delete from contenidopedido where nopedido='$nopedido'";

$cs=mysql_query($sql,$cn);
echo "<script> alert('Se elimnino correctamente');</script>";
}
}

?>
<form name="fe" action="" method="post">
<center>
No pedido:
<?php
$sql="select max(nopedido) from contenidopedido";
$result=mysql_query($sql);
print_r ($result);
?>
<tr>
<td width="117">Fecha: <?php echo date("m/d/Y"); ?></td>
<td width="143">Solicitado por: <? echo $_SESSION["usuarioactual"]; ?></td><br>


<table border="2">
<tr>
<td>No pedido</td>
<td><input name="txtnopedido" type="text" value="<?php echo $var?>" size="6"/></td>
</tr>
<tr>
<td>Productos</td>
<td><input name="txtnopro" type="text" value="<?php echo $var1?>" size="6"/></td>
</tr>
<tr>
<td>Cantidad</td>
<td><input name="txtcantidad" type="text" value="<?php echo $var2?>" size="6"/></td>
</tr>
<tr>
<td>Observaciones</td>
<td><textarea name="txtobs" cols="6" id="txtobs"><?php echo $var3?></textarea></td>
</tr>
<tr>


<tr align="center">
<td colspan="2"><input type="submit" name="btn1" value="Nuevo"/><a href="pedidos.php"></a>
<input type="submit" name="btn1" value="Listar Todo"/></td>
</tr>
<tr align="center"><td colspan="2"><input type="submit" name="btn1"value="Eliminar"/>
<input type="submit" name="btn1"value="Agregar"/></td></tr>
</table>

</center>
<br />
<hr>
</form>
<br />



<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];

if($btn=="Listar Todo"){

$sql="select * from contenidopedido order by nopedido";
$cs=mysql_query($sql,$cn);
echo"<center>
<table border='3'>
<tr>
<td>NO pedido</td>
<td>Producto</td>
<td>Cantidad</td>
<td>Observaciones</td>
</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];


echo "<tr>
<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>


</tr>";
}

echo "</table>
</center>";
}
}
?>
<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];

if($btn=="Agregar"){

$sql="select * from contenidopedido where nopedido='$nopedido'";
$cs=mysql_query($sql,$cn);
echo"<center>
<table border='3'>
<tr>
<td>NO pedido</td>
<td>Producto</td>
<td>Cantidad</td>
<td>Observaciones</td>
</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];


echo "<tr>
<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>


</tr>";
}

echo "</table>
</center>";
}
}
?>