Consulta php

Iniciado por alexkof158, 5 Noviembre 2009, 05:16 AM

0 Miembros y 1 Visitante están viendo este tema.

alexkof158

buenas resulta ketengo un pequeño problemilla, estoy realizando en php una aplicacion que consulte por id_cliente en una base de datos el parametro en un input en otro html aparte  ::)
, aki ta el cod
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>consultar</title>
</head>

<body>

<h1>Consultar por Código del Cliente</h1>
<br>
<form action="view.php" method="post">
Ingrese ID:<input type="text" name="consult" id="consult"/> <br />
<input type="submit" name="boton" id="boton" value="Buscar" />&nbsp;
</form>
<br />
<br>
<br>


</body>

</html>

<?php 
$consult
=$_GET['consult'];
$link mysql_connect("localhost""root","") or die ("ha ocurrido un error en la conexion");
mysql_select_db("empresa"$link) or die ("no se ha podido seleccionar la base de datos");
$result mysql_query("SELECT * FROM clientes WHERE id_cliente=$consult"$link)or die("Error en la consulta SQL"); 
if (
mysql_num_rows($result)){ 
  echo 
"<table border = '1'> \n"
  echo 
"<tr><td>Codigo</td><td>Nombres</td><td>Apellidos</td><td>Direccion</td><td>Ciudad</td><td>Email</td><td>Telefono</td></tr> \n"
  while (
$row = @mysql_fetch_array($result)) { 
    echo 
"<tr><td>".$row["id_cliente"].
      
"</td><td>".$row["nombres"]."</td>
<td>"
.$row["apellidos"]."</td>
<td>"
.$row["direccion"]."</td>
<td>"
.$row["ciudad"]."</td>
<td>"
.$row["email"]."</td>
<td>"
.$row["telefono"]."</td></tr> \n";

  }
  echo 
"</table> \n"
}
else
  echo 
"No Se ha encontrado ningun registro";
printf("<a href= busquedad.php>volver</a>");  
?>

</body>
</html>

Pero al momento de enviar la consultar por un input no me muestra la consulta..
pues solo me muestra el mensaje de error (die)
que hago mal??
gracias y saludos ;D
"noproxy"

DarkItachi

#1
Código (php) [Seleccionar]
<form action="view.php" method="post">
Código (php) [Seleccionar]
$consult=$_GET['consult'];

Arregló eso tu duda?

Si no mira la respuesta abajo.

Código (php) [Seleccionar]
$consult=$_POST['consult']; Estabas transfiriendo la variable por post e intentabas recibirla con get, por eso no te funcionaba.

Saludos.
Come to me when you have these eyes...

By more that you try it, a feather never will achieve to fly.