Non l'ho provato, ma secondo me potrebbe funzionare un codice del genere:
Codice PHP:
<?
class CategoryProvider{
var $query;
public function __construct(){
//Istruzioni di connessione al db
$sql="Select * From List_Categorie";
$this->query = mysql_query($sql) or die (mysql_error);
}
public function readNext(){
return mysql_fetch_assoc($this->query);
}
}
$foo = new CategoryProvider();
while ( $row = $foo->readNext() ) {
echo "{$row['id_Categoria']} - {$row['Nome_Categoria']}";
}
?>