Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: classe per html

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802

    classe per html

    salve a tutti sto lavorando su una classe che mi crea del codice html , però avrei un problema , che non mi incrementa il contenuto , perche ?
    Codice PHP:

    class phpHtml
    {
        var 
    $tabid "" ;
        var 
    $cellpadding "" ;
        var 
    $cellspacing "" ;
        var 
    $tableborder "" ;
        var 
    $width "" ;
        var 
    $tbclass "" ;
        var 
    $style "" ;
        var 
    $tabtitle "" ;
        var 
    $cssFilePath "";
        var 
    $columHeader = array();
        var 
    $columContent = array();
        var 
    $columContentTr = array();
        var 
    $trclass "" ;
        var 
    $trtitle "" ;
        var 
    $onmouseover "" ;
        var 
    $onmouseout "" ;
        var 
    $onclick "" ;
        var 
    $trid "" ;
        var 
    $trstyle "" ;
         
         function 
    setTableFormat($tabid ""$cellpadding ""$cellspacing ""$tableborder ""$width ""$tbclass ""$style ""$tabtitle "")
         {
            
    $this->tabid       $tabid;
            
    $this->cellpadding $cellpadding;
            
    $this->cellspacing $cellspacing;
            
    $this->tableborder $tableborder;
            
    $this->width       $width;
            
    $this->tbclass     $tbclass;
            
    $this->style       $style;
            
    $this->tabtitle    $tabtitle;
        }

         function 
    setTableTr($trclass ""$trtitle ""$onmouseover ""$onmouseout ""$onclick ""$trid ""$trstyle "")
         {
            
    $this->trclass       $trclass;
            
    $this->trtitle       $trtitle;
            
    $this->onmouseover   $onmouseover;
            
    $this->onmouseout    $onmouseout;
            
    $this->onclick       $onclick;
            
    $this->trid          $trid;
            
    $this->trstyle       $trstyle;
        }

         function 
    printTableHeader()
         {
            echo 
    '<table id = "'.$this->tabid.'" cellpadding = "'.$this->cellpadding.'" cellspacing = "'.$this->cellspacing.'" border = "'.$this->tableborder.'" width = "'.$this->width .'" class = "'.$this->tbclass.'" style = "'.$this->style.'" title = "'.$this->tabtitle.'">'."\n";
       
            if(
    count($this->columHeader)>0)
            {
              echo 
    "<thead>\n";
                echo 
    "<tr>\n";
                
            if(
    count($this->columHeader)>0)
            {     
                echo 
    '<td class="tcat" width="1" align="left" nowrap>[img]space.gif[/img]</td>';
            }
                
            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'].'"'
                if(!empty(
    $this->columHeader[$ii]['width']))    echo 'width   = "'.$this->columHeader[$ii]['width'].'"';
                if(!empty(
    $this->columHeader[$ii]['height']))   echo 'height  = "'.$this->columHeader[$ii]['height'].'"'
                if(!empty(
    $this->columHeader[$ii]['colspan']))  echo 'colspan = "'.$this->columHeader[$ii]['colspan'].'"';
                if(!empty(
    $this->columHeader[$ii]['align']))    echo 'align   = "'.$this->columHeader[$ii]['align'].'"';  
                if(!empty(
    $this->columHeader[$ii]['valign']))   echo 'valign  = "'.$this->columHeader[$ii]['valign'].'"';  
                echo 
    'nowrap="nowrap">';
                echo 
    $this->columHeader[$ii]['title'];
                echo 
    '</td>'."\n";
            }
                echo 
    '</tr>'."\n";
              echo 
    '</thead>'."\n";
            }
         }

         function 
    printTableHeaderContent()
         {
           echo 
    $this->printTableHeader();
          
             if(
    count($this->columHeader) > 0){
                echo 
    '<tbody>'."\n";
                echo 
    '<tr>'."\n";
                echo 
    '<td class="contenttableborder" colspan="'. (count($this->columHeader)+1) .'">'."\n";
                echo 
    '<table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";      
             }else{
                echo 
    '<tr>'."\n";
                echo 
    '<td class="contenttableborder" colspan="'. (count($this->columHeader)+1) .'">'."\n";
                echo 
    '<table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";
             }
         }

         function 
    printTableFotter()
         {
                echo 
    '</table>'."\n";
         }

         function 
    printTableFotterContent()
         {
             if(
    count($this->columHeader) > 0){
                echo 
    '</table></td></tr></tbody></table>';
             }else{
                echo 
    '</table></td></tr></table>';
             }
        }
        
         function 
    printDataContent()
         {
           
    $count 0;
           
    $style = ($count == 0) ? "row1" "row2";     
           if(!empty(
    $this->trclass)){
           
    $background $this->trclass;
           }else{
           
    $background $style;
           }
          echo 
    '<tr class="'.$background.'" title="'.$this->trtitle.'" onmouseover="'.$this->onmouseover.'" onmouseout="'.$this->onmouseout.'" onclick="'.$this->onclick.'" id="'.$this->trid.'" style="'.$this->trstyle.'" >';
            for (
    $wow=0$wow<count($this->columContent); $wow++)
            {
                echo 
    '<td';
                if(!empty(
    $this->columContent[$wow]['id']))       echo 'id      = "'.$this->columContent[$wow]['id'].'"'
                if(!empty(
    $this->columContent[$wow]['class']))    echo 'class   = "'.$this->columContent[$wow]['class'].'"'
                if(!empty(
    $this->columContent[$wow]['width']))    echo 'width   = "'.$this->columContent[$wow]['width'].'"';
                if(!empty(
    $this->columContent[$wow]['height']))   echo 'height  = "'.$this->columContent[$wow]['height'].'"'
                if(!empty(
    $this->columContent[$wow]['colspan']))  echo 'colspan = "'.$this->columContent[$wow]['colspan'].'"';
                if(!empty(
    $this->columContent[$wow]['align']))    echo 'align   = "'.$this->columContent[$wow]['align'].'"';  
                if(!empty(
    $this->columContent[$wow]['valign']))   echo 'valign  = "'.$this->columContent[$wow]['valign'].'"';  
                echo 
    '>';
                echo 
    $this->columContent[$wow]["value"];
                echo 
    '</td>'."\n";
            }
          echo 
    '</tr>';
          
    $count ++;    
         }
        
         function 
    printTable()
         {
           echo 
    '<link href="'.$this->cssFilePath.'" rel="stylesheet" type="text/css">';
           
    $this->printTableHeaderContent();
           
    $this->printDataContent();
           
    $this->printTableFotterContent();
         }

    mi stampa soltanto un valore che sarebbe l ultimo :la classe la richiamo cosi
    Codice PHP:
        require_once "../php_table.php";
        
    $phpHtml = new phpHtml();
        
    $phpHtml->cssFilePath "../php_sort_table.css";
        
    $phpHtml->setTableFormat("","0","0","0","900","tborder");
        
    $phpHtml->columHeader[0]['class']='tcat';
        
    $phpHtml->columHeader[0]['title']='primo titol';



        
    $phpHtml->columContent[0]['value'] = "test 1";
        
    $phpHtml->columContent[1]['value'] = "test 1";
        
    $phpHtml->columContent[2]['value'] = "test 1";
        
    $phpHtml->columContent[3]['value'] = "test 1";
        
    $phpHtml->columContent[0]['value'] = "test 2";
        
    $phpHtml->columContent[1]['value'] = "test 2";
        
    $phpHtml->columContent[2]['value'] = "test 2";
        
    $phpHtml->columContent[3]['value'] = "test 2";
        
    $phpHtml->printTable();
    echo 
    '<pre>';
    print_r($phpHtml); 
    codice:
    phpHtml Object
    (
        [tabid] => 
        [cellpadding] => 0
        [cellspacing] => 0
        [tableborder] => 0
        [width] => 900
        [tbclass] => tborder
        [style] => 
        [tabtitle] => 
        [cssFilePath] => ../php_sort_table.css
        [columHeader] => Array
            (
                [0] => Array
                    (
                        [class] => tcat
                        [title] => primo titol
                    )
    
            )
    
        [columContent] => Array
            (
                [0] => Array
                    (
                        [value] => test 2
                    )
    
                [1] => Array
                    (
                        [value] => test 2
                    )
    
                [2] => Array
                    (
                        [value] => test 2
                    )
    
                [3] => Array
                    (
                        [value] => test 2
                    )
    
            )
    
        [columContentTr] => Array
            (
            )
    
        [trclass] => 
        [trtitle] => 
        [onmouseover] => 
        [onmouseout] => 
        [onclick] => 
        [trid] => 
        [trstyle] => 
    )
    perche ?
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802
    qual' cuno mi potrebbe aiutare per favore grazie
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  3. #3
    Devi spiegare meglio cosa non ti va.
    Per me non incrementa il contenuto non significa niente.

    Cosa devi fare? Quale parte del codice dà problemi? Cosa dovrebbe incrementare?

    Non siamo indovini :master:

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802
    ciao il problema e : che non mi incrementa i dati che invio


    mi stampa a video solo l ultimo dato ti posto un esempio
    Codice PHP:
    $phpHtml->columContent[0]['value'] = "test 1"
        
    $phpHtml->columContent[1]['value'] = "test 1"
        
    $phpHtml->columContent[2]['value'] = "test 1"
        
    $phpHtml->columContent[3]['value'] = "test 1"
        
    $phpHtml->columContent[0]['value'] = "test 2"
        
    $phpHtml->columContent[1]['value'] = "test 2"
        
    $phpHtml->columContent[2]['value'] = "test 2"
        
    $phpHtml->columContent[3]['value'] = "test 2"
        
    $phpHtml->printTable(); 
    dovrebbe stampare
    <tr><td>test 1</td><td>test 1</td><td>test 1</td></tr>
    <tr><td>test 2</td><td>test 2</td><td>test 2</td></tr>

    invece mi estrae solo l' ultima
    <tr><td>test 2</td><td>test 2</td><td>test 2</td></tr>
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2009
    Messaggi
    114
    1) se il tuo host ha php 5.x, ti consiglio di cambiare sintassi abbandonando la vecchia struttura delle classi che hai utilizzato tu (prorpia del php 4)

    2) è normale che non funzioni, nell'ultimo pezzo di codice da te presentato semplicemente stai inserendo due volte un valore allo stesso indice di un array:

    Codice PHP:
    $phpHtml->columContent[3]['value'] = "test 1"
    ...
    $phpHtml->columContent[3]['value'] = "test 2"
    Scrivendo cosi come hai fatto tu stai dicendo a php "metti test 1 nell'array e dopo sovrascrivilo con test 2". E' assolutamente corretto.
    Al limite dovresti utilizzare, se vuoi usare indici sequenziali, una sintassi del genere:

    Codice PHP:
    $phpHtml->columContent[] = array("value"=>"test 1"); 
    $phpHtml->columContent[] = array("value"=>"test 2"); 
    oppure usando la magic function __set con php 5 per "reinvetarti" la funzione di set della tua classe.

    Gabriele

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802
    ciao e grazie , comunque uguale non m ' incrementa i dati , poi con le classi ho iniziato a studiarle da poco , se mi daresti una mano per favore ho un po ritoccato un po la classe cosi
    Codice PHP:


    error_reporting
    (E_ALL);


    class 
    phpHtml
    {
        var 
    $tabid "" ;
        var 
    $cellpadding "" ;
        var 
    $cellspacing "" ;
        var 
    $tableborder "" ;
        var 
    $width "" ;
        var 
    $tbclass "" ;
        var 
    $style "" ;
        var 
    $tabtitle "" ;
        var 
    $cssFilePath "";
        
        
        var 
    $trclass "" ;
        var 
    $trtitle "" ;
        var 
    $onmouseover "" ;
        var 
    $onmouseout "" ;
        var 
    $onclick "" ;
        var 
    $trid "" ;
        var 
    $trstyle "" ;

        
        var 
    $colHead = array();    
        var 
    $colSet = array();    
        
        
        
        
         function 
    setTableFormat($tabid ""$cellpadding ""$cellspacing ""$tableborder ""$width ""$tbclass ""$style ""$tabtitle "")
         {
            
    $this->tabid       $tabid;
            
    $this->cellpadding $cellpadding;
            
    $this->cellspacing $cellspacing;
            
    $this->tableborder $tableborder;
            
    $this->width       $width;
            
    $this->tbclass     $tbclass;
            
    $this->style       $style;
            
    $this->tabtitle    $tabtitle;
        }

         function 
    setTableTr($trclass =""$trtitle =""$onmouseover =""$onmouseout =""$onclick =""$trid =""$trstyle ="")
         {
            
    $this->trclass       $trclass;
            
    $this->trtitle       $trtitle;
            
    $this->onmouseover   $onmouseover;
            
    $this->onmouseout    $onmouseout;
            
    $this->onclick       $onclick;
            
    $this->trid          $trid;
            
    $this->trstyle       $trstyle;
        }

         function 
    printTableHeader()
         {
            echo 
    '<table id = "'.$this->tabid.'" cellpadding = "'.$this->cellpadding.'" cellspacing = "'.$this->cellspacing.'" border = "'.$this->tableborder.'" width = "'.$this->width .'" class = "'.$this->tbclass.'" style = "'.$this->style.'" title = "'.$this->tabtitle.'">'."\n";
       
            if(
    count($this->colHead)>0)
            {
              echo 
    "<thead>\n";
                echo 
    "<tr>\n";
            if(
    count($this->colHead)>0)
            {     
                echo 
    '<td class="tcat" width="4" align="left" nowrap>[img]space.gif[/img]</td>'."\n";
            }
            for(
    $ii=0$ii<count($this->colHead); $ii++)
            {
                echo 
    '<td ';
                if(!empty(
    $this->colHead[$ii]['id'])) echo ' id = "'.$this->colHead[$ii]['id'].'"'
                if(!empty(
    $this->colHead[$ii]['class'])) echo ' class = "'.$this->colHead[$ii]['class'].'"'
                if(!empty(
    $this->colHead[$ii]['width'])) echo ' width = "'.$this->colHead[$ii]['width'].'"';
                if(!empty(
    $this->colHead[$ii]['height']))echo ' height = "'.$this->colHead[$ii]['height'].'"'
                if(!empty(
    $this->colHead[$ii]['colspan']))echo ' colspan = "'.$this->colHead[$ii]['colspan'].'"';
                if(!empty(
    $this->colHead[$ii]['align'])) echo ' align = "'.$this->colHead[$ii]['align'].'"';  
                if(!empty(
    $this->colHead[$ii]['valign']))echo ' valign = "'.$this->colHead[$ii]['valign'].'"';  
                echo 
    ' nowrap>';
                echo 
    $this->colHead[$ii]['title'];
                echo 
    '</td>'."\n";
            }
                echo 
    '</tr>'."\n";
              echo 
    '</thead>'."\n";
            }
         }

         function 
    printTableHeaderContent()
         {
            
    $this->printTableHeader();
             if(
    count($this->colHead) > 0){
                echo 
    '<tbody><tr><td class="contenttableborder" colspan="'. (count($this->colHead)+1) .'"><table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";      
             }else{
                echo 
    '<tr><td class="contenttableborder" colspan="'. (count($this->colHead)+1) .'"><table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";
             }
         }

         function 
    printTableFotter()
         {
             echo 
    '</table>'."\n";
         }

         function 
    printTableFotterContent()
         {
             if(
    count($this->colHead)>0){
                echo 
    '</table></td></tr></tbody></table>';
             }else{
                echo 
    '</table></td></tr></table>';
             }
        }
        
         function 
    printDataContent()
         {
           
    $count 0;
           
           
    $style = ($count == 0) ? "row1" "row2";     
           if(!empty(
    $this->trclass)){
           
    $background $this->trclass;
           }else{
           
    $background $style;
           }
             echo 
    '<tr class="'.$background.'" ';
          if(!empty(
    $this->trtitle))echo ' title="'.$this->trtitle.'"';
          if(!empty(
    $this->onmouseover))echo ' onmouseover="'.$this->onmouseover.'"';
          if(!empty(
    $this->onmouseout))echo ' onmouseout="'.$this->onmouseout.'"';
          if(!empty(
    $this->onclick))echo ' onclick="'.$this->onclick.'"';
          if(!empty(
    $this->trid))echo ' id="'.$this->trid.'"';
          if(!empty(
    $this->trstyle))echo ' style="'.$this->trstyle.'"';
          echo
    ' >';

             for(
    $xx=0$xx<count($this->colSet); $xx++)
            {    
                echo 
    '<td ';
                if(!empty(
    $this->colSet[$xx]['id']))     echo ' id = "'.$this->colSet[$xx]['id'].'"'
                if(!empty(
    $this->colSet[$xx]['class']))  echo ' class = "'.$this->colSet[$xx]['class'].'"'
                if(!empty(
    $this->colSet[$xx]['width']))  echo ' width = "'.$this->colSet[$xx]['width'].'"';
                if(!empty(
    $this->colSet[$xx]['height'])) echo ' height = "'.$this->colSet[$xx]['height'].'"'
                if(!empty(
    $this->colSet[$xx]['colspan']))echo ' colspan = "'.$this->colSet[$xx]['colspan'].'"';
                if(!empty(
    $this->colSet[$xx]['align']))  echo ' align = "'.$this->colSet[$xx]['align'].'"';  
                if(!empty(
    $this->colSet[$xx]['valign'])) echo ' valign = "'.$this->colSet[$xx]['valign'].'"';  
                echo 
    '>';
                echo 
    $this->colSet[$xx]['value'];
                echo 
    '</td>'."\n";
            }
          echo 
    '</tr>';
          
    $count ++;    
         }
        
         function 
    printTable()
         {
           echo 
    '<link href="'.$this->cssFilePath.'" rel="stylesheet" type="text/css">';
           
    $this->printTableHeaderContent();
           
    $this->printDataContent();
           
    $this->printTableFotterContent();
         }

    Rocco Chiolo
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802
    ragazzi salve scusate mi potreste dare una mano? perche non mi incrementano i dati? cosa potrei fare?
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  8. #8
    Se non riporti anche il codice con cui richiami la classe non è facile aiutarti...

    Comunque, per riprendere il codice che avevi scritto precedentemente: se lo modifichi così cosa succede?
    Codice PHP:
        $phpHtml->columContent[0]['value'] = "test 1"
        
    $phpHtml->columContent[1]['value'] = "test 1"
        
    $phpHtml->columContent[2]['value'] = "test 1"
        
    $phpHtml->columContent[3]['value'] = "test 1"
        
    $phpHtml->printTable();
        
    $phpHtml->columContent[0]['value'] = "test 2"
        
    $phpHtml->columContent[1]['value'] = "test 2"
        
    $phpHtml->columContent[2]['value'] = "test 2"
        
    $phpHtml->columContent[3]['value'] = "test 2"
        
    $phpHtml->printTable(); 
    Continuo a non capire comunque cosa intendi per "non incrementa i dati".
    Vuoi dire che "non stampa le righe successive alla prima"?

    Facci sapé..

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,802
    ciao facendo il codice come mi hai consigliato mi radoppia tutto il contenuto , sarebbe a dire due tabelle ti posto come richiamo la classe
    Codice PHP:

    <link href="../php_sort_table.css" rel="stylesheet" type="text/css" />
    <?php 


    $conne 
    mysql_connect("localhost","root","maurizio");
    $dbmysql_select_db("guru",$conne );

        
    $res mysql_query("SELECT * FROM tblusers");
        


        require_once 
    "../function_html.php";
        
    $phpHtml = new phpHtml();
        
            
    $phpHtml->setTableFormat ("","0","0","0","100%","tborder"); // cellpadding, cellspacing, border

        
        
    $phpHtml->colHead[0]['title'] = "test 2";
        
       
    $phpHtml->colSet[0]['value'] = "test 2"
        
    $phpHtml->colSet[1]['value'] = "test 2"
        
    $phpHtml->colSet[2]['value'] = "test 2"
        
    $phpHtml->colSet[3]['value'] = "test 2"
        
    $phpHtml->printTable();
       
    $phpHtml->colSet[0]['value'] = "test 2"
        
    $phpHtml->colSet[1]['value'] = "test 2"
        
    $phpHtml->colSet[2]['value'] = "test 2"
        
    $phpHtml->colSet[3]['value'] = "test 2"
        
    $phpHtml->printTable();
     echo 
    '<pre>';   print_r($phpHtml); 
    ?>
    e posto la classe :
    Codice PHP:

    class phpHtml
    {
        var 
    $tabid "" ;
        var 
    $cellpadding "" ;
        var 
    $cellspacing "" ;
        var 
    $border "" ;
        var 
    $width "" ;
        var 
    $class "" ;
        var 
    $style "" ;
        var 
    $tabtitle "" ;
        var 
    $cssFilePath "phpSortTable/php_sort_table.css";
        var 
    $imgFilePath "phpSortTable/img/";
        
        var 
    $trclass "" ;
        var 
    $trtitle "" ;
        var 
    $onmouseover "" ;
        var 
    $onmouseout "" ;
        var 
    $onclick "" ;
        var 
    $trid "" ;
        var 
    $trstyle "" ;

        
        var 
    $colHead = array();    
        var 
    $colSet = array();    
        var 
    $rowSet = array();
        
        function 
    __construct() {
        }
        
         function 
    setTableFormat($tabid ""$cellpadding ""$cellspacing ""$border ""$width ""$class ""$style ""$tabtitle "")
         {
            
    $this->tabid       = (string)$tabid;
            
    $this->cellpadding = (string)$cellpadding;
            
    $this->cellspacing = (string)$cellspacing;
            
    $this->border      = (string)$border;
            
    $this->width       = (string)$width;
            
    $this->class       = (string)$class;
            
    $this->style       = (string)$style;
            
    $this->tabtitle    = (string)$tabtitle;
        }

         function 
    setTableTr($trclass =""$trtitle =""$onmouseover =""$onmouseout =""$onclick =""$trid =""$trstyle ="")
         {
            
    $this->trclass       = (string)$trclass;
            
    $this->trtitle       = (string)$trtitle;
            
    $this->onmouseover   = (string)$onmouseover;
            
    $this->onmouseout    = (string)$onmouseout;
            
    $this->onclick       = (string)$onclick;
            
    $this->trid          = (string)$trid;
            
    $this->trstyle       = (string)$trstyle;
        }

         function 
    printTableHeader()
         {
         
         
    $tabid        =  ($this->tabid != "")        ? ' id = "'.$this->tabid.'"'                  '';
         
    $cellpadding  =  ($this->cellpadding != "")  ? ' cellpadding = "'.$this->cellpadding.'"'   '';
         
    $cellspacing  =  ($this->cellspacing != "")  ? ' cellspacing = "'.$this->cellspacing.'"'   '';
         
    $border       =  ($this->border != "")       ? ' border = "'.$this->border.'"'             '';
         
    $width        =  ($this->width != "")        ? ' width = "'.$this->width .'"'              '';
         
    $class        =  ($this->class != "")        ? ' class = "'.$this->class.'"'               '';
         
    $style        =  ($this->style != "")        ? ' style = "'.$this->style.'"'               '';
         
    $tabtitle     =  ($this->tabtitle != "")     ? ' title = "'.$this->tabtitle.'"'            '';
         
          echo 
    '<table '.$tabid $cellpadding $cellspacing $border $width $class $style $tabtitle.'  >'."\n";
       
            if(
    count($this->colHead)>0)
            {
              echo 
    "<thead>\n";
                echo 
    "<tr>\n";
          
            if(
    count($this->colHead)>0)
            {     
                echo 
    '<td class="tcat" width="1" align="left" nowrap>[img]space.gif[/img]</td>';
            }
          
            for(
    $ii=0$ii<count($this->colHead); $ii++)
            {
              
                echo 
    '<td ';
                if(!empty(
    $this->colHead[$ii]['id'])) echo ' id = "'.$this->colHead[$ii]['id'].'"'
                if(!empty(
    $this->colHead[$ii]['class'])) echo ' class = "'.$this->colHead[$ii]['class'].'"'
                if(!empty(
    $this->colHead[$ii]['width'])) echo ' width = "'.$this->colHead[$ii]['width'].'"';
                if(!empty(
    $this->colHead[$ii]['height']))echo ' height = "'.$this->colHead[$ii]['height'].'"'
                if(!empty(
    $this->colHead[$ii]['colspan']))echo ' colspan = "'.$this->colHead[$ii]['colspan'].'"';
                if(!empty(
    $this->colHead[$ii]['align'])) echo ' align = "'.$this->colHead[$ii]['align'].'"';  
                if(!empty(
    $this->colHead[$ii]['valign']))echo ' valign = "'.$this->colHead[$ii]['valign'].'"';  
                echo 
    ' nowrap>';
                echo 
    $this->colHead[$ii]['title'];
                echo 
    '</td>'."\n";
            }
                echo 
    '</tr>'."\n";
              echo 
    '</thead>'."\n";
            }
         }

         function 
    printTableHeaderContent()
         {
             if(
    count($this->colHead) > 0){
              echo 
    $this->printTableHeader();
                echo 
    '<tbody><tr><td class="contenttableborder"  colspan="'. (count($this->colHead[0]['title'])+1) .'"><table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";      
             }else{
              echo 
    $this->printTableHeader();         
                echo 
    '<tr><td class="contenttableborder"  colspan="1"><table border="0" cellpadding="3" cellspacing="1" width="100%">'."\n";
             }
         }

         function 
    printTableFotter()
         {
             echo 
    '</table>'."\n";
         }

         function 
    printTableFotterContent()
         {
             if(
    count($this->colHead)>0){
                echo 
    '</table></td></tr></tbody></table>';
             }else{
                echo 
    '</table></td></tr></table>';
             }
        }
        
         function 
    printDataContent()
         {
           
           
           
           
    $count 0;
           
    $style = ($count == 0) ? "row1" "row2";     
           
           
           
           
    $tr_class  =  ($this->trclass != "")         ? ' class = "'.$this->trclass.'"'           ' class = "'.$style.'"';
           
    $tr_title  =  ($this->trtitle != "")         ? ' title = "'.$this->trtitle.'"'           '';
           
    $tr_onmouseover =  ($this->onmouseover != "")? ' onmouseover = "'.$this->onmouseover.'"' '';
           
    $tr_onmouseout  =  ($this->onmouseout != "") ? ' onmouseout = "'.$this->onmouseout.'"'   '';
           
    $tr_onclick  =  ($this->onclick != "")       ? ' onclick = "'.$this->onclick.'"'         '';
           
    $tr_id  =  ($this->trid != "")               ? ' id = "'.$this->trid.'"'                 '';
           
    $tr_style  =  ($this->trstyle != "")         ? ' style = "'.$this->trstyle.'"'           '';
          
        
          

         
          echo 
    '<tr '.$tr_class $tr_title $tr_onmouseover $tr_onmouseout $tr_onclick $tr_id $tr_style '  >';

            for(
    $xx=0$xx<count($this->colSet); $xx++)
           {    
            
           
    $tdC_id      =  (isset($this->colSet[$xx]['id']))      ? ' id = "'.$this->colSet[$xx]['id'].'"'           '';
           
    $tdC_class   =  (isset($this->colSet[$xx]['class']))   ? ' class = "'.$this->colSet[$xx]['class'].'"'     '';
           
    $tdC_width   =  (isset($this->colSet[$xx]['width']))   ? ' width = "'.$this->colSet[$xx]['width'].'"'     '';
           
    $tdC_height  =  (isset($this->colSet[$xx]['height']))  ? ' height = "'.$this->colSet[$xx]['height'].'"'   '';
           
    $tdC_colspan =  (isset($this->colSet[$xx]['colspan'])) ? ' colspan = "'.$this->colSet[$xx]['colspan'].'"' '';
           
    $tdC_align   =  (isset($this->colSet[$xx]['align']))   ? ' align = "'.$this->colSet[$xx]['align'].'"'     '';
           
    $tdC_valign  =  (isset($this->colSet[$xx]['valign']))  ? ' valign = "'.$this->colSet[$xx]['valign'].'"'   '';
            
                echo 
    '<td '.$tdC_id.$tdC_class.$tdC_width.$tdC_height.$tdC_colspan.$tdC_align.$tdC_valign.'>';
                echo 
    $this->colSet[$xx]['value'];
                echo 
    '</td>'."\n";
           }
          echo 
    '</tr>';
          
    $count ++;    
         }
        
         function 
    printTable()
         {
           echo 
    '<link href="'.$this->cssFilePath.'" rel="stylesheet" type="text/css">';
           
    $this->printTableHeaderContent();
           
    $this->printDataContent();
           
    $this->printTableFotterContent();
         }

    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  10. #10
    Non mi sono spiegato:
    devi usare un
    Codice PHP:
        $phpHtml->colSet[0]['value'] = "test 2"
        
    $phpHtml->colSet[1]['value'] = "test 2"
        
    $phpHtml->colSet[2]['value'] = "test 2"
        
    $phpHtml->colSet[3]['value'] = "test 2"
        
    $phpHtml->printTable(); 
    Per ogni riga che vuoi stampare.

    Ovviamente se gli dai due volte le stesse identiche istruzioni ti stampa due volte la stessa cosa.
    Se ci fai caso la prima volta dò il valore "test 1" e la seconda volta dò il valore "test2", proprio per evidenziare questo fatto.

    Metti ad ogni valore che assegni un valore diverso.

    Per esempio:
    Codice PHP:
        $phpHtml->colSet[0]['value'] = "Colonna 1, Riga 1"
        
    $phpHtml->colSet[1]['value'] = "Colonna 2, Riga 1"
        
    $phpHtml->colSet[2]['value'] = "Colonna 3, Riga 1"
        
    $phpHtml->colSet[3]['value'] = "Colonna 4, Riga 1"
        
    $phpHtml->printTable(); 
        
    $phpHtml->colSet[0]['value'] = "Colonna 1, Riga 2"
        
    $phpHtml->colSet[1]['value'] = "Colonna 2, Riga 2"
        
    $phpHtml->colSet[2]['value'] = "Colonna 3, Riga 2"
        
    $phpHtml->colSet[3]['value'] = "Colonna 4, Riga 2"
        
    $phpHtml->printTable(); 

    Vedrai che la doppia riga in realtà non è doppia

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.