Código PHP:
<?
conectaserver("10.7.3.25","root","","marxismo","mysql");
$consulta = mysql_query("SELECT * FROM noticias GROUP BY categoria ORDER BY idnoticia LIMIT 3");
$resultado = mysql_fetch_array($consulta);
switch ($resultado['categoria']){
case "1":
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2><img src=img/nacionales.gif border=0 alt='Nacionales'></td>
</tr>";
break;
case "2":
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2><img src=img/internacionales.gif border=0 alt='Internacionales'></td>
</tr>";
break;
case "3":
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2><img src=img/asign.gif border=0 alt='De la asignatura'></td>
</tr>";
break;
case "4":
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2><img src=img/escolares.gif border=0 alt='De la escuela'></td>
</tr>";
break;
default:
echo "<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2>No hay categorías en la BD</td>
</tr>";
break;
}
while ($result = mysql_fetch_array($consulta)){
$idlectura = $result['idnoticia'];
echo "<tr>
<td rowspan=3><div align=center><img src=img/".$result['imagen']." alt='".$result['altimage']."' border=0 width=204 height=154></div></td>
<td valign=bottom><span class=newstitle>".$result['titulo']."</td>
</tr>
<tr>
<td valign=top><span class=txt>".$result['resumen']."</td>
</tr>
<tr>
<td valign=top><span class=txt><a href=noticias.php?accion=mostrar&cat=".$categoria."&idnoticia=".$idlectura.">Ver más[+]</a></td>
</tr>";
}
echo "</table>";
?>