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 ?mi stampa soltanto un valore che sarebbe l ultimo :la classe la richiamo cosiCodice 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 % 2 == 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();
}
}
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);
perche ?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] => )

 
			
			 
					
					
					
						 Rispondi quotando
  Rispondi quotando