Código:
En el index.php (ya contiene el include de la clase) va lo siguiente:<?php include ('config.inc.php'); class Conexion{ private $serv; private $user; private $pass; private $base; private $conect; function __construct($serv, $user, $pass, $base){ $this->serv = $serv; $this->user = $user; $this->pass = $pass; $this->base = $base; $this->conectar(); } private function conectar(){ $this->conect = mysql_connect ($this->host, $this->user, $this->pass)or die ("error en conexion"); mysql_select_db ($this->base, $this->conect); } } class Datos{ function mostrar(){ $this->resultado = mysql_query("SELECT titulo, contenido FROM post ORDER BY id ASC", $this->conect); $resu = mysql_fetch_array($this->resultado,MYSQL_ASSOC); while($resu){ echo " ".$resu['titulo']." - ".$resu['contenido']." <br/>"; } } } ?>
Código:
Bueno, muchas gracias, no me insulten mucho! $mostrar = new Datos(); $mostrar->mostrar();
Gustavo.