Ver Mensaje Individual
  #14 (permalink)  
Antiguo 10/07/2014, 12:32
galaktico
 
Fecha de Ingreso: julio-2008
Mensajes: 57
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Consulta Página Detalle / Maestro con PHP

Les paso como quedaron los códigos de mis archivos:

Conexion.php:

<?php
$Conexion = mysql_connect('localhost', 'root', '') or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db('base', $Conexion);
?>

Resultado.php:

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

$Consulta = "SELECT * FROM productos";
$resultado = mysql_query($Consulta, $Conexion) or die(mysql_error());
$fila = mysql_fetch_assoc($resultado);
$totalfilas = mysql_num_rows($resultado);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<table width="320" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Nombre</td>
<td>Ver Detalles</td>
</tr>
<?php
while($fila=mysql_fetch_array($resultado)) { ?>
<tr>
<td><?php echo $fila["nombre"]; ?></td>
<td><a href="detalle.php?id_producto=<?php echo $fila['id_producto']; ?>" target="_self">SI</a></td>
</tr>
<?php } ?>
</table>
</body>
</html>

Detalle.php:

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

$Consulta = "SELECT * FROM productos WHERE id_producto = $_GET ['id']";
$resultado = mysql_query($Consulta, $Conexion) or die(mysql_error());
$fila = mysql_fetch_assoc($resultado);
$totalfilas = mysql_num_rows($resultado);

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<table width="320" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Nombre</td>
<td>Categoria</td>
</tr>
<tr>
<td><?php echo $fila["nombre"]; ?></td>
<td><?php echo $fila["categoria"]; ?></td>
</tr>
</table>
</body>
</html>

Pero ahora me da el siguiente error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '['id'_producto]' at line 1

Me podrán ayudar?

Muchas gracias!