Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/02/2006, 17:55
eximer
 
Fecha de Ingreso: diciembre-2004
Mensajes: 103
Antigüedad: 19 años, 5 meses
Puntos: 0
Linkear dinamicamente

Hola a todos. Les cuento, estoy haciendo un sistema de noticias que tiene dos tablas "noticias " y "tipo_noticias" que vienen a ser las categorias.
Estoy haciendo a través de un while una botonera para que me despliegue de forma dinamica todas las categorias que tengo y para que al hacer click en algun link me muestre todas las noticias que corresponden a esa categoria. Ahora bien, me falta corregir este codigo para crear el enlace, no se en si en una o mas parte esta mal, me las muestra bien, pero no se como linear eso.
Dejo tambien las tablas de mi bd, por si sirven de ayuda.
GRACIAS!!!

botonera.php
Código:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilo.css">
</head>

<body bgcolor="#FFFFFF">
<?
// Listado de ctegoria o tipo de noticias
if ($tipo == "buscar")
{

// Armo el formulario de busqueda

?> <?

}
else
{

// Listamos los tipos de noticias
// Armo una conexion al servidor mysql
$coneccion = mysql_connect($host_db, $user_db, $pass_db);
mysql_select_db($base_db, $coneccion);

$sql = "select * from tipo_noticias where desc_tipo_noticia like '%$buscar%' ";
$result = mysql_query($sql, $coneccion);

if (mysql_error())
{
echo "ERROR al agregar categoria - ".
mysql_errno().":". mysql_error()."<br>";
}

// Calculo la cantidad de resultados
$cant_resultados = mysql_num_rows($result);

if ($cant_resultados >=1)
{

?> <?

while($myrow = mysql_fetch_array($result))
{

?> 
<table width="220" border="0" cellspacing="3" cellpadding="0">
  <tr> 
    <td align="right" bgcolor="#D5DAD5" width="205" height="16"><font color="#6280B4"><font color="#495661"><a href="#"><? echo
$myrow[desc_tipo_noticia];?> </a> </font><font color=#ffffff>&nbsp; </font></font></td>
    <td width="16" height="16" bgcolor="#D5DAD5" align="center"><font color="#495661"><b>&raquo;</b></font></td>
  </tr>
</table>
<?
} // end while

}
else
{
echo "No se han encontrado resultados coincidentes<br>";
}
}

?>
</body>
</html>
[B]tablas/B]
Código:
CREATE TABLE noticias (
`id_noticia` INT( 5 ) NOT NULL AUTO_INCREMENT ,
`dtime` TEXT,
`titulo` VARCHAR( 255 ) default NULL,
`subtitulo` VARCHAR( 255 ) default NULL,
`text1` TEXT,
`text2` TEXT,
`imagen` VARCHAR( 255 ) default NULL,
`cod_tipo_noticia` INT( 2 ) default NULL,
PRIMARY KEY ( `id_noticia` ) ,
INDEX ( `cod_tipo_noticia` ) 
);

CREATE TABLE tipo_noticias (
`id_tipo_noticia` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`desc_tipo_noticia` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id_tipo_noticia` ) 
);

CREATE TABLE usuarios ( 
id smallint(5) unsigned not null auto_increment, 
fecha int(10) unsigned not null, 
nick varchar(20) not null, 
contrasena varchar(20) not null, 
email varchar(40) not null, 
registro varchar(5) null, 
apellido varchar(30) null, 
nombre varchar(30) null, 
descripcion text null, 
ip varchar(15) not null, 
primary key (id), 
key (nick,contrasena) 
);