salve ragazzi dovrei inserire dentro un array il contenuto di una query tipo
Codice PHP:

                
echo '[url='$sortLink ']'.$column->title .'[/url]';
            if(
$this->sortby == $column->name)
                echo 
'[img]'.$this->imgFilePath $this->sortimg .'[/img]'
cosi :
Codice PHP:

            
echo '[url='$sortLink ']'.$this->columContent[$index][$column->title] .'[/url]';
            if(
$this->sortby == $column->name)
                echo 
'[img]'.$this->imgFilePath $this->sortimg .'[/img]'
questa e la classe
Codice PHP:
error_reporting(E_ALL);

class 
Grid
{
    var 
$tableName;
    var 
$urlKeyName;
    var 
$tableKeyName;
    var 
$editLink "" ;
    var 
$editTarget;
    var 
$editWindowFormat;
    var 
$deleteLink "" ;
    var 
$addLink;
    var 
$addTarget;
    var 
$addText;
    var 
$editPromptMsg;
    var 
$deletePromptMsg;
    var 
$asc_img;
    var 
$desc_img;
    var 
$edit_img;
    var 
$delete_img;
    var 
$add_img;
    var 
$cellpadding "" ;
    var 
$cellspacing "" ;
    var 
$tableborder "" ;
    var 
$width "" ;
    var 
$tbclass "" ;
    var 
$style "" ;
    var 
$columHeader = array();
    var 
$columContent = array();
    var 
$tableTitle "" ;
    var 
$defaultRowsNum;
    var 
$imgFilePath;
    var 
$cssFilePath;
    var 
$emptyMsg;
    var 
$columns;
    var 
$selfLink;
    var 
$urlVars;  
    var 
$totalRows;
    var 
$shownRows;
    var 
$colsNum;
    var 
$rows;
    var 
$offset;
    var 
$sortby;

     function 
__construct($connectionData$tableName) {
        
$this->connectionData $connectionData;
        
$this->tableName $tableName;
        
$this->imgFilePath "phpSortTable/img/";
        
$this->cssFilePath "phpSortTable/php_sort_table.css";
        
$this->asc_img "asc.gif";
        
$this->desc_img "desc.gif";
        
$this->add_img "add.gif";
        
$this->delete_img "delete.gif";
        
$this->edit_img "edit.gif";
        
$this->defaultRowsNum 5;
        
$this->emptyMsg "No data to be shown.";
        
$this->editWindowFormat "";
    }
    
      function 
Grid($connectionData$tableName) {
        
$this->connectionData $connectionData;
        
$this->tableName $tableName;
        
$this->imgFilePath "phpSortTable/img/";
        
$this->cssFilePath "phpSortTable/php_sort_table.css";
        
$this->asc_img "asc.gif";
        
$this->desc_img "desc.gif";
        
$this->add_img "add.gif";
        
$this->delete_img "delete.gif";
        
$this->edit_img "edit.gif";
        
$this->defaultRowsNum 5;
        
$this->emptyMsg "No data to be shown.";
    }

     function 
setPackageFilePath ($path) {
        
$this->packageFilePath $path;
    }
    
     function 
connect(){
        
$connParam explode(","$this->connectionData4);
        
$host $connParam[0];
        
$db $connParam[1];
        
$user $connParam[2];
        
$pass $connParam[3];
        
$connection mysql_connect($host$user$pass) or die(mysql_error());
        
mysql_select_db($db$connection) or die(mysql_error());
        return 
$connection;
    }
    
     function 
start($name$title$selectquery$countquery$searchquery$fields$options){
     }
     function 
setTableFormat($cellpadding ""$cellspacing ""$tableborder ""$width ""$tbclass ""$style ""
     {
        
$this->cellpadding $cellpadding;
        
$this->cellspacing $cellspacing;
        
$this->tableborder $tableborder;
        
$this->width       $width;
        
$this->tbclass     $tbclass;
        
$this->style       $style;
    }
    
    
    
    
     function 
printTable()
     {

        if (!empty(
$_REQUEST["offset"]) && is_numeric($_REQUEST["offset"]))
        {
            
$this->offset $_REQUEST["offset"];
        } else {
            
$this->offset "0";
        }
        
$this->sortby  = isset($_REQUEST['sortby'])?$_REQUEST['sortby']:'';     // column to sort
        
$this->sortdir = isset($_REQUEST['sortdir'])?$_REQUEST['sortdir']:'';     // sort direction
        
$this->rows    = isset($_REQUEST['rows'])?$_REQUEST['rows']:'';         // amount of rows to be shown
        
        
        
        
if (substr($_SERVER['SCRIPT_NAME'] , -4) == '.php'){
        
$this->selfLink $_SERVER['SCRIPT_NAME'] . '?';
        }else{
        
$this->selfLink $_SERVER['SCRIPT_NAME'] . '&';
        }
        if (
substr($this->urlVars , -4) == '.php'){
        
$this->urlVars "" '?';
        }else{
        
$this->urlVars "" '&';
        }
        
        foreach (
$_GET as $key => $value
        {
            if((
$key != "sortby") && ($key != "rows") && ($key != "offset") && ($key != "sortdir")) {
            
                
$this->selfLink .=  $key '=' $value;
                
                
$this->urlVars .= '&' $key '=' $value;
            }
        }
        
        if (
strlen($this->sortdir) < 1){$this->sortdir "ASC";}
        if (
strlen($this->rows) < 1){
            
$this->rows $this->defaultRowsNum;

        }

        
$connection $this->connect();

        
$sql "SELECT * FROM " $this->tableName;
        
/*         #appends the WHERE clause if it exists
        if (strlen($this->whereClause) > 0)
            $sql .= $this->whereClause;
 */        
        
if (strlen($this->sortby) > 0)
            
$sql .= " ORDER BY " $this->sortby " " $this->sortdir;
            
$sql .= " LIMIT " $this->offset ", " $this->rows;

            
$sqlT "SELECT * FROM " $this->tableName;
        
/* #appends the WHERE clause if it exists
        if (strlen($this->whereClause) > 0)
            $sqlT .= $this->whereClause;
 */
        # executes the queries
        
$select mysql_query($sql$connection) or die(mysql_error());
        
/* $selectT = mysql_query($sqlT, $connection) or die(mysql_error()); */

        # changes the sort direction now for the Columns
        
$this->sortdir = ($this->sortdir == "ASC") ? "ASC" "DESC";
        
$this->sortimg = ($this->sortdir == "ASC") ? $this->asc_img $this->desc_img;
        
$this->totalRows mysql_num_rows($select);
        
$this->shownRows mysql_num_rows($select);
        
$this->colsNum count($this->columns);

        
        echo 
'<link href="'.$this->cssFilePath.'" rel="stylesheet" type="text/css">';

        
/* $this->printTitle(); */
        
        # if table is empty, shows the Empty Message
        
if ($this->totalRows 1) {
            
$this->printEmptyMsg();
        }else{
            
$this->printHeader();
            
$this->printContent($select);
        }
        
        
$this->printFooter();
        
        
        
mysql_close($connection);
    }

      function 
printHeader(){
    
    
      echo 
'<table cellpadding="'.$this->cellpadding.'" cellspacing="'.$this->cellspacing.'" border="'.$this->tableborder.'" width="'.$this->width .'" class="'.$this->tbclass.'" style="'.$this->style.'">';
     
           
      if(
count($this->columHeader) > 0) {
        echo 
"<thead>";
          echo 
"<tr>";
            for(
$ii=0$ii<count($this->columHeader); $ii++){
             echo 
'<td id =  "tab'.$this->columHeader[$ii].'"';
                if(!empty(
$this->columHeader[$ii]['class']))    echo 'class   = '.$this->columHeader[$ii]['class'].'';   else echo $this->columHeader[$ii]['class'] = '';
                if(!empty(
$this->columHeader[$ii]['width']))    echo 'width   = '.$this->columHeader[$ii]['width'].'';   else echo $this->columHeader[$ii]['width'] = '';
                if(!empty(
$this->columHeader[$ii]['height']))   echo 'height  = '.$this->columHeader[$ii]['height'].'';  else echo $this->columHeader[$ii]['height'] = '';
                if(!empty(
$this->columHeader[$ii]['colspan']))  echo 'colspan = '.$this->columHeader[$ii]['colspan'].''; else echo $this->columHeader[$ii]['colspan'] = '';
                if(!empty(
$this->columHeader[$ii]['align']))    echo 'align   = '.$this->columHeader[$ii]['align'].'';   else echo $this->columHeader[$ii]['align'] = '';
                if(!empty(
$this->columHeader[$ii]['valign']))   echo 'valign  = '.$this->columHeader[$ii]['valign'].'';  else echo $this->columHeader[$ii]['valign'] = '';
             echo 
'nowrap="nowrap">';
         echo 
$this->columHeader[$ii]['title'] ;
        echo  
'</td>';
        }
        echo 
"</tr>";
      echo 
"</thead>";
      }
    
    
        if(
substr($_SERVER['SCRIPT_NAME'] , -4) == '.php'){
        
$this->selfLink $_SERVER['SCRIPT_NAME'] . '?';
        }else{
        
$this->selfLink $_SERVER['SCRIPT_NAME'] . '&';
        }
    
        
$index=0;
        echo 
'<tr id="headerRow">';
        foreach(
$this->columns as $column)
        {    
            
$sortLink $this->selfLink 'rows=' .$this->rows.'&offset='.$this->offset;
            
$sortLink .= '&sortby='.$column->name;
            
$sortLink .= ($this->sortdir == 'ASC') ? '&sortdir=DESC' '&sortdir=ASC';
            
            echo 
'<td id="headerCell"'
                if(!empty(
$this->columContent[$index]['class']))    echo 'class   = '.$this->columContent[$index]['class'].'';   else echo $this->columContent[$index]['class'] = '';
                if(!empty(
$this->columContent[$index]['width']))    echo 'width   = '.$this->columContent[$index]['width'].'';   else echo $this->columContent[$index]['width'] = '';
                if(!empty(
$this->columContent[$index]['height']))   echo 'height  = '.$this->columContent[$index]['height'].'';  else echo $this->columContent[$index]['height'] = '';
                if(!empty(
$this->columContent[$index]['colspan']))  echo 'colspan = '.$this->columContent[$index]['colspan'].''; else echo $this->columContent[$index]['colspan'] = '';
                if(!empty(
$this->columContent[$index]['align']))    echo 'align   = '.$this->columContent[$index]['align'].'';   else echo $this->columContent[$index]['align'] = '';
                if(!empty(
$this->columContent[$index]['valign']))   echo 'valign  = '.$this->columContent[$index]['valign'].'';  else echo $this->columContent[$index]['valign'] = '';
             echo 
'nowrap="nowrap">';
                               
                echo 
'[url='$sortLink ']'.$this->columContent[$index][$column->title] .'[/url]';
            if(
$this->sortby == $column->name)
                echo 
'[img]'.$this->imgFilePath $this->sortimg .'[/img]';
                
                
            echo 
'</td>';
        }
        if (
strlen($this->editLink) > 0)
            echo 
"<td></td>";
        if (
strlen($this->deleteLink) > 0)
            echo 
"<td></td>";
        echo 
"</tr>";
        
$index++;
    }
    
     function 
printContent($query)
     {
        
$count 0;    
        while(
$row mysql_fetch_array($query))
        {
            
$style = ($count == 0) ? "contentRow1" "contentRow2";
            
            echo 
'<tr id="'$style .'" >';

            foreach (
$this->columns as $key => $column
            {
                echo 
'<td id="contentCell">';
            
                    echo  
htmlspecialchars($row[$column->name]);
                
                echo 
'</td>';
            }
            
$key $this->urlKeyName;
            
$keyVal $row[$this->tableKeyName];
        
        
            if (
strlen($this->editLink) > 0){
                if (
substr($this->editLink , -4) == '.php'){
                   
$eLink $this->editLink "?" $this->urlKeyName "=" $row[$this->tableKeyName] . $this->urlVars;
                } else {
                   
$eLink $this->editLink "&" $this->urlKeyName "=" $row[$this->tableKeyName] . $this->urlVars;
                }
                echo 
'<td width="2%" alt="edit" title="edit">';
                echo 
'<a href='.$eLink.'>';
                
                echo 
'[img]'.$this->imgFilePath .$this->edit_img '[/img]';
                echo 
"</a>";
                echo 
"</td>";
            }
            if (
strlen($this->deleteLink) > 0){
                if (
substr($this->deleteLink , -4) == '.php'){
                   
$dLink $this->deleteLink '?' $this->urlKeyName '=' $row[$this->tableKeyName] . $this->urlVars;
                } else {
                   
$dLink $this->deleteLink '&' $this->urlKeyName '=' $row[$this->tableKeyName] . $this->urlVars;
                }
                echo 
'<td width="2%" alt="delete" title="delete">';
                echo 
'<a href='.$dLink.' >';
                echo 
'[img]'.$this->imgFilePath.$this->delete_img.'[/img]';
                echo 
'</a>';
                echo 
'</td>';
            }
            echo 
'</tr>';
            
$count++;
        }
        echo 
'<table>';
    }
    
     function 
printFooter() {

     }
     function 
printEmptyMsg() {
        echo 
'<table id="contentTable" "'.$this->formatString.'">';
        echo 
'<tr id="contentRow1"><td></td></tr>';
        echo 
'<tr id="contentRow1">';
        echo 
'<td id="emptyMsg">"'.$this->emptyMsg'"</td>';
        echo 
'</tr>';
        echo 
'<tr id="contentRow1"><td></td></tr>';
        echo 
'</table>';
    }

}
class 
displayGrid {

    var 
$name;
    var 
$title;
    function 
__construct ($name$title) {
        
$this->name $name;
        
$this->title $title;
    }