Codice PHP:
function getRows() {
        if(!
$this->_sql) {
            
$this->_error 'Query to select rows not set. Call method setSqlSelect()';
            return 
false;
        }
        if(!
$this->_connection) {
            
$this->_error 'Database connection not set. Call method setConnection()';
            return 
false;
        }
        
$cr 0;
        
$p $this->_page 1;
        If(
$p 0) {$p 0;}
        
$p $this->_rowsperpage $p;
        
$result mysql_query ($this->_sql " LIMIT $p{$this->_rowsperpage}"$this->_connection);
        if(!
$result) {
            
$this->_error 'Error: ' mysql_error();
            return 
false;
        }
        
        if (
mysql_num_rows($result) == 0) {
            return 
'';
        }
        
        
$classodd $classeven '';        
        if(
$this->classodd) {
            
$classodd ' class="' $this->classodd '"';
        }
        if(
$this->classeven) {
            
$classeven ' class="' $this->classeven '"';
        }
        
        
$r '';
        while (
$row mysql_fetch_assoc($result)) {
            
$c '';
            
            foreach(
$row as $key=>$field) {
                
$c .= $this->fmtField($key$field);
            }
            
$r .= sprintf($this->tr$cr $classodd $classeven$c);
            
$cr $cr;
        }
        return 
$r;
    } 
Ciao a tutti.Devo modificare una classe che prende dei record dal db e li impagina 10 per pagina.La classe funziona correttamente,ma vorrei fare una piccola modifica...
Con la funzione che ho postato sopra io ottengo i record e l'impagino nei td...
Come posso aggiungere oltre ai campi del db,al primo td un ciclo che parte da 1 e aumenti per ogni record impaginato...
Se non sono stato chiaro o devo postare altri dettagi fatemi sapere