Dejo la tabla y codigo que tengo hasta ahora:
Cita:
Pagina con el formulario para crear cada noticia:CREATE TABLE `noticias` (
`id` int(10) NOT NULL auto_increment,
`titulo` varchar(50) NOT NULL,
`fecha` date NOT NULL,
`noticia` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
`id` int(10) NOT NULL auto_increment,
`titulo` varchar(50) NOT NULL,
`fecha` date NOT NULL,
`noticia` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>administrar</title>
</head>
<body>
<form action="sistnoticias.php" method="post">
Título noticia:<br>
<input type="text" name="titulo"><br>
Escriba el articulo<br>
<textarea name="articulo" cols="50" rows="10"></textarea><br>
<input type="submit" value="Publicar"><br>
</form>
<?php
$noticia=$_POST['articulo'];
$fecha=date('y-m-d');
$titulo=$_POST['titulo'];
if($noticia!="" and $titulo!=""){
include('db-cnx.php');
mysql_query("insert into noticias(titulo,fecha,noticia) values('$titulo','$fecha','$noticia')");
}
?>
</body>
</html>
Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<?php
include('db-cnx.php');
$re=mysql_query('select * from noticias order by id desc ');
while($f=mysql_fetch_array($re)){
echo '<tr>'.$f['fecha'].'</td><br />';
echo '<tr><a href="noticia.php?id='.$f['id'].'">'.$f['titulo'].'</a></td></tr><br /><br />';
}
?>
</body>
</html>
Código PHP:
<?php
include('db-cnx.php');
$re=mysql_query('select * from noticias where id ="'.$_GET['id'].'" ');
while($f=mysql_fetch_array($re)){
echo '<tr>'.$f['fecha'].'</td><br />';
echo '<tr>'.$f['titulo'].'</td></tr><br /><br />';
echo '<tr>'.$f['noticia'].'</td></tr><br /><br />';
}
?>
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
Desde ya gracias.