Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/05/2016, 17:05
BESTINGENIEROEVER
 
Fecha de Ingreso: mayo-2016
Mensajes: 1
Antigüedad: 8 años
Puntos: 0
Proyecto de grado

Hola gente. Necesito ayuda urgente con este codigo porfavor el problema principal es que cuando le doy en el botón buscar me busca todos los campos que tengo (Nombre videojuego , telefono, precio , correo y cantidad) EXCEPTO EL CAMPO DE TIPO no se que hacer sinceramente cabe recalcar que el campo de tipo es un menu desplegable adjunto el codigo. Estare muy agradecido por sus opiniones

<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Inventario</title>
<link rel="stylesheet" href="style/index_style.css">

</head>
<body>
<h1 align="center" font face="arial">INFOMAC PROYECTS</h1></align></font><br>
<h3 align="center" font face="arial">INVENTARIO</h3></align></font>
<header>

<div class="contenedor" id="uno">
<a href="index.php"><img class="icon" src="pictures/icon1.png"></a>
<p class="texto">Inicio</p>
</div>

<div class="contenedor" id="dos">
<a href="inventario.php"><img class="icon" src="pictures/icon2.png"></a>
<p class="texto">Inventario</p>
</div>

<div class="contenedor" id="tres">
<a href="registro.php"><img class="icon" src="pictures/icon3.png"></a>
<p class="texto">Registro</p>
</div>

<div class="contenedor" id="cuatro">
<a href="compras.php"><img class="icon" src="pictures/icon4.png"></a>
<p class="texto">Compras</p>
</div>

<div class="contenedor" id="cinco">
<a href="logout.php"><img class="icon" src="pictures/icon5.png"></a>
<p class="texto">Cerrar Sesion</p>
</div>

<div class="contenedor" id="seis">
<img class="icon" src="pictures/icon6.png">
<p class="texto">Contactenos</p>
</div>

</header>

<center><td><h2>Seleccione lo que desea Buscar:<br></h2></center><p>

<center><a href="inv_Coonsolas.php">Consolas</a> <a href="inv_videojuego.php">Videojuegos</a> <a href="inv_accesorios.php">Accesorios</a> <a href="inv_bonos.php">Bonos</a></center><p>
<?php

include("conexion.php");


$nombrejuego="";
$tipo="";
$telefono="";
$correo="";
$precio="";
$cantidad="";

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

$sql="SELECT * from inv_juegos where nombre_juego='$bus'";
$cs=mysql_query($sql) or die ("error en consulta" . mysql_error() );
while($resul=mysql_fetch_array($cs)){
$nombrejuego=$resul[0];
$tipo=$resul[1];
$telefono=$resul[2];
$correo=$resul[3];
$precio=$resul[4];
$cantidad=$resul[5];
}
if($tipo=="tipo"){
$tipo="selected";
}
}


if($btn=="Enviar"){
$nombrejuego=$_POST['nombrejuego_'];
$tipo=$_POST['tipo_'];
$telefono=$_POST['telefono_'];
$correo=$_POST['correo_'];
$precio=$_POST['precio_'];
$cantidad=$_POST['cantidad_'];
$sql="INSERT INTO inv_juegos(nombre_juego,tipo,telefono,correo,preci o,cantidad) values ('$nombrejuego','$tipo','$telefono','$correo','$pr ecio','$cantidad')";


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

if($btn=="Modificar"){
$nombrejuego=$_POST['nombrejuego_'];
$tipo=$_POST['tipo_'];
$telefono=$_POST['telefono_'];
$correo=$_POST['correo_'];
$precio=$_POST['precio_'];
$cantidad=$_POST['cantidad_'];

$sql="update inv_juegos set tipo= '$tipo',telefono='$telefono',correo='$correo',prec io='$precio',cantidad='$cantidad' where nombre_juego='$nombrejuego'";

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

if($btn=="Eliminar"){
$nombrejuego=$_POST["nombrejuego_"];

$sql="delete from inv_juegos where nombre_juego='$nombrejuego'";

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

?>
<form action="" method="POST">
<center><table border="0">
<td colspan="4"><h2 align="center">VIDEOJUEGOS</h2></td><br>
<tr>
<td>Nombre Videojuego:</td>
<td><input type="text" name="nombrejuego_" value ="<?php echo $nombrejuego?>"size="20"></td>
<td>Tipo:</td>
<td>
<select name="tipo_"value="<?php echo $tipo?>" >
<option value=></option>
<option value=PS4>PS4</option>
<option value=PS2>PS2</option>
<option value=PS3>PS3</option>
<option value=WII>WII</option>
<option value=PSVITA>PSVITA</option>
<option value=XBOX-ONE>XBOX-ONE</option>
<option value=XBOX360>XBOX360</option>
<option value=PC>PC</option>
</select></td>
<td align="left" colspan="1"><input type="submit" name="btn" value="Buscar"></td>
</tr>
<tr>
<td>telefono:</td>
<td><input type="text" name="telefono_" value ="<?php echo $telefono?>"size="20"></td>
<td>Correo:</td>
<td><input type="text" name="correo_" value ="<?php echo $correo?>"size="20"></td>
<td align="left" colspan="1"><input type="submit" name="btn" value="Modificar"></td>
</tr>
<tr>
<td>Precio:</td>
<td><input type="text" name="precio_" value ="<?php echo $precio?>"size="20"></td>
<td>Cantidad:</td>
<td><input type="text" name="cantidad_" value ="<?php echo $cantidad?>"size="20"></td>
<td align="left" colspan="1"><input type="submit" name="btn" value="Eliminar"></td>
</tr>
<tr>
<td align="left" colspan="2"><input type="submit" name="btn" value="Enviar"></td></align>
<td align="left" colspan="2"><a href="inventario.php"><input type="button" value="Volver"></td></align></a>
</tr>
</form><form name="listar" method="post"><td align="center" colspan="4"><input type="submit" name="btn2" value="Listar">
</table></table></form><br>
<?php
if(isset($_POST["btn2"])){
$btn=$_POST["btn2"];

if($btn=="Listar"){
include("conexioon.php");
$sql="select * from inv_juegos";
$cs=mysql_query($sql,$cn);
echo"<center>
<table border='3'>
<td>Nombre del Videojuego</td>
<td>Tipo</td>
<td>telefono</td>
<td>correo</td>
<td>precio</td>
<td>cantidad</td>
</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
echo
"<tr>

<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
<td>$var4</td>
<td>$var5</td>

</tr>";
}

echo "</table>
</center>";
}
}
?><br>
</body>
</html>