A ver q tal esta idea ¿?
Código PHP:
class Noticia
{
var $titulo;
var $texto;
var $fecha;
var $autor;
function Noticia ($titulo, $texto, $autor,$fecha)
{
$this->titulo = $titulo;
$this->texto = $texto;
$this->autor = $autor;
$this->fecha = $fecha;
}
function Muestra()
{
$content = "<table width=\"100%\">";
$content .= "<tr><th>$this->titulo</th><th>$this->fecha)</th></tr>";
$content .= "<tr><td>$this->texto</td><td>;nbsp</td></tr>";
$content .= "<tr><td>;nbsp</td><td>$this->autor</td></tr>";
$content .="</table>";
return $content;
}
}
index.php
Código PHP:
...conexion, query y demas,.....
include ('class-noticias.php');
$news = new Noticia($row["titulo"],$row["texto"],$row["autor"],$row["fecha"]);
$news->Muestra();
Visto lo visto, con mi ejemplo no parece muy necesario usar una clase. Pero espero q te sirva :D
Un saludo.