Saludos.
Tengo montado un sistema de noticias con resumen, este es el código:
Código PHP:
<html>
<head>
<style type="text/css">
table
{
width: auto;
position: relative;
display: block;
border: thin solid black;
}
th,h1
{
background: Blue;
color: White;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
}
p
{
margin: 0;
clear: left;
display: table-row;
}
</style>
</head>
<?php
//conexión a la base de datos
$con = mysql_connect("xxx","xxx","xxx") or die (mysql_error());
mysql_select_db("sistemanoticias",$con) or die (mysql_error());
// verificamos si se ha enviado
// alguna variable via GET
if(isset($_GET['id']) && $_GET['categoria']){
// asignamos los valores
// a las variables que usaremos
$cat_ID = $_GET['id'];
$categoria = $_GET['categoria'];
$clausula = "WHERE notCategoriaID = '$cat_ID'";
// tambien armamos el titular de la pagina
$titulo = "Noticias en la categoria $categoria";
}else{
// de lo contrario
// el titulo sera general
$titulo = "Todas las noticias";
}
// armamos la consulta
$_pagi_sql = "SELECT notTitulo, notTexto FROM sn_noticias
WHERE notCategoriaID = '$cat_ID'"
or die(mysql_error());
//cantidad de resultados por página (opcional, por defecto 20)
$_pagi_cuantos = 5;
//Incluimos el script de paginación. Éste ya ejecuta la consulta automáticamente
include("paginator.inc.php");
echo "<h1>$titulo</h1>";
// mostramos las noticias,
// otra vez usando un bucle while
while($rowNot = mysql_fetch_array($_pagi_result)){
echo "<th><h1>$rowNot[notTitulo]</h1></th>";
echo nl2br (substr(($rowNot['notTexto']),0,150)) . "...";
echo "<a href=\"vernoticia.php?id_noticia=" . $rowNot['not_ID'] . "\" title=\"Ver noticia completa\">Ver noticia completa</a>";
}
//Incluimos la barra de navegación
echo $_pagi_navegacion;
?>
</html>
Ahora el otro fichero vernoticia.php
Código PHP:
<html>
<head>
<style type="text/css">
table
{
width: auto;
position: relative;
display: block;
border: thin solid black;
}
th,h1
{
background: Blue;
color: White;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
}
p
{
margin: 0;
clear: left;
display: table-row;
}
</style>
</head>
<?php
//conexión a la base de datos
$con = mysql_connect("xxx","xxx","xxx") or die (mysql_error());
mysql_select_db("sistemanoticias",$con) or die (mysql_error());
// verificamos si se ha enviado
// alguna variable via GET
if(isset($_GET['id']) && $_GET['categoria']){
// asignamos los valores
// a las variables que usaremos
$id_noticia = $HTTP_GET_VARS['id_noticia'];
$cat_ID = $_GET['id'];
$categoria = $_GET['categoria'];
$clausula = "WHERE notCategoriaID = '$cat_ID'";
// tambien armamos el titular de la pagina
$titulo = "Noticias en la categoria $categoria";
}else{
// de lo contrario
// el titulo sera general
$titulo = "Todas las noticias";
}
// armamos la consulta
$_pagi_sql = "SELECT notTitulo, notTexto FROM sn_noticias"
or die(mysql_error());
//Incluimos el script de paginación. Éste ya ejecuta la consulta automáticamente
include("paginator.inc.php");
echo "<h1>$titulo</h1>";
// mostramos las noticias,
// otra vez usando un bucle while
while($rowNot = mysql_fetch_array($_pagi_result)){
echo "<th><h1>$rowNot[notTitulo]</h1></th>";
echo nl2br (($rowNot['notTexto']));
}
?>
</html>
Qué me falta aquí?.
Muchas Gracias.