Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/03/2006, 11:21
Borjimante
Invitado
 
Mensajes: n/a
Puntos:
Aqui el codigo index:

Cita:
<?php
include ("conexion.php");
if (!isset($id)) {

$sql="SELECT * FROM noticias";
$resultado=mysql_query($sql);
$total=mysql_num_rows($resultado);

echo " <h3>Hay un total de $total noticias.</h3><p>";

while ($row=mysql_fetch_array($resultado))
{
$id= $row['id'];
$titular= $row['titular'];
$noticia= $row['noticia'];

echo "<li><b><a href=\"index.php?id=$id\">$titular</b></li>";


}
mysql_free_result($resultado);
}else{

$sql="SELECT * FROM noticias where id='$id'";
$resultado=mysql_query($sql);
echo " <a href=\"index.php\">Ver todas las noticias</a><p>";
while ($row=mysql_fetch_array($resultado))
{
$id= $row['id'];
$titulares= $row['titular'];
$noticia= $row['noticia'];

echo "<li><b>$titulares</b></li><br>";
echo "$noticia";

}
mysql_free_result($resultado);
mysql_close($conexio);
}
?>
Y esto es la base de datos:

Cita:
CREATE TABLE `noticias` (
`id` int(11) NOT NULL auto_increment,
`titular` varchar(240) NOT NULL default '',
`noticia` text NOT NULL,
KEY `id` (`id`),
FULLTEXT KEY `noticia` (`noticia`),
FULLTEXT KEY `titular` (`titular`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Volcar la base de datos para la tabla `noticias`
--

INSERT INTO `noticias` VALUES (1, 'Mi 1º noticia', 'Comprobando mi 1º noticia.');
INSERT INTO `noticias` VALUES (2, '2º titular', 'mas de lo mismo');
Haber si me puedes ayudar