Esta es la tabla noticia:
Código:
Este es el index.php `id` int(1) NOT NULL auto_increment, `titulo` varchar(255) NOT NULL default '', `subtitulo` text NOT NULL, `detalle` text NOT NULL, `fuente` varchar(255) NOT NULL default '', `categoria_id` int(1) NOT NULL, `subcategoria` varchar(140) NOT NULL default '', `foto` varchar(140) NOT NULL default '', `fecha` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
Código PHP:
<?php
$sql="select * FROM noticia, categoria WHERE noticia.categoria_id = categoria.categoria_id ORDER BY id DESC LIMIT 21";
$res=mysql_query($sql,$con);
?>
<div class="noticia">
<table width="100%" cellspacing="5" >
<?php
$i=0;
while($mostrador = mysql_fetch_array($res))
{
$i++;
?>
<tr id="<?php echo "id_$i";?>">
<td width="33%" align="center" valign="top">
<div align="justify">
<p>Fecha: <?php echo $mostrador["fecha"];?></p>
<table width="auto" cellspacing="1" cellpadding="3" border="0" bgcolor="#<?php echo $mostrador["categoria_color"];?>"><tr>
<td valign="top"><font color="#FFFFFF" face="arial, verdana, helvetica">
<b><?php echo $mostrador["categoria_nombre"];?>: <?php echo $mostrador["subcategoria"];?></b>
</font></td>
</tr></table>
<?php
echo "<a href=administrador/ver-noticias.php?id=$mostrador[id]>"; ?> <h1><?php echo $mostrador["titulo"];?></h1></a>
<img src="imagenes/<?php echo $mostrador["foto"];?>" />
<p><?php echo $mostrador["subtitulo"];?></p>
</div>
</tr>
<?php
}
?>
</table>
</div>