Ver Mensaje Individual
  #8 (permalink)  
Antiguo 05/06/2008, 07:27
Avatar de floppy-dj
floppy-dj
 
Fecha de Ingreso: diciembre-2006
Ubicación: Huelva
Mensajes: 25
Antigüedad: 17 años, 5 meses
Puntos: 0
Respuesta: PROBLEMA con include y switch

Al final lo que he hecho a sido esto:


CABECERA.PHP
Código PHP:
<a href="index.php?car=MONITORES">Monitores</a>
<
a href="index.php?car=DISCOS">Discos</a>
<
a hr........ 
CONTENIDO.PHP
Código PHP:
<?php
$categoria
=$_GET['cat'];
echo 
$categoria;
//conectamos con la base de datos...
$cn=mysql_connect("localhost","root","");
$db=mysql_select_db("tienda",$cn);
$cons="select * from productos where categoria='$categoria'";
echo 
$cons."<br>";
$query=mysql_query($cons,$cn);


?>
<table align="center" border="1">
<tr>
<th>Imagen</th>
<th>Nombre</th>
<th>Categoria</th>
<th>Descripcion</th>
<th>Precio</th>
</tr>
<?php

while ($row=mysql_fetch_array($query))
{

echo 
"<tr><td><a href=".$row['imageng']."><center><img src=".$row['imagen']."></center></a></td>";
echo 
"<td>".$row['nombre']."</td>";
echo 
"<td><CENTER>".$row['categoria']."</CENTER></td>";
echo 
"<td>".$row['descripcion']."</td>";
echo 
"<td><CENTER>".$row['precio']."</CENTER></td></tr>";
}
mysql_free_result($result)
?>
Asi de esta forma solo tengo tres archivos, index.php, cabecera.php y contenido.php.

Y asi contenido.php va cojiendo los datos de la base de datos con tan solo una consulta, aun salen un par de errores pero se corregiran.

NOTA: NO ME AYUDO NADIE, aunque buestras aportaciones me han ayudado y me han servido para sacar esto.

Gracias.