Foros del Web » Programando para Internet » PHP »

tabla html

Estas en el tema de tabla html en el foro de PHP en Foros del Web. buenas: alguien conoce de alguna libreria para php que te permita armar tablas mas lindas "esteticamente" para mostrar resultados de consultas en mysql. Desde ya ...
  #1 (permalink)  
Antiguo 04/06/2007, 10:51
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
tabla html

buenas:
alguien conoce de alguna libreria para php que te permita armar tablas mas lindas "esteticamente" para mostrar resultados de consultas en mysql.

Desde ya muchas gracias
  #2 (permalink)  
Antiguo 04/06/2007, 10:58
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: tabla html

Te paso esta que uso, el uso es bastante simple:
Código PHP:
$table = new GeckoTable( array( "cellspacing" => 0"cellpadding" => 0"class" => "myTable" ) );
$table->addHeader"ID" );
$table->addHeader"Name" );
$table->addHeader"Options", array( "colspan" => ) );
$table->addRow();
$table->addCell);
$table->addCell"Fulanito" );
$table->addCell$modifyLink );
$table->addCell$deleteLink );

echo 
$table
La clase:
Código PHP:
<?php
/**
 * GeckoTable
 * 
 * @package com.gkdev.utils;
 * @copyright Copyright (c) 2008
 * @access public
 **/
class GeckoTable {
    private 
$_html_string;     // @var private string variable that holds all of HTML and Table properties
    
private $_rows;         // @var private integer variable that holds the total rows
    
private $_tbody_open// @var private boolean variable that holds if a table body is open
    
private $_row_open;
    
    
/**
     * Constructor
     *
     * Creates a new Instance of a Object Oriented Table
     *
     * @param array $table_props Table properties
     * @access public
     **/
    
public function __construct$table_props = array()  ) {
        
$table_properties     '';
        
$table_properties     $this->prop2String$table_props );
        
$this->_html_string "<table$table_properties>\n";
        
$this->_rows 0;
        
$this->_tbody_open false;
        
$this->_row_open false;
    }
    
    
/**
     * prop2String
     * 
     * Converts a array of key/value pairs to a attribute string
     * ej:
     *     array(
     *         'attrib1' => 'value1',
     *     );
     * to:
     *     attrib1="value1" (escaped)
     *
     * @param array $properties Array of properties
     * @acccess private
     * @return string converted array
     **/
    
private function prop2String$properties ) {
        
$properties_str '';
        foreach( 
$properties as $property => $value ) {
            
$properties_str .= " $property=\"$value\"";
        }

        return 
$properties_str;
    }
    
    
/**
     * addCaption
     * 
     * Adds a Caption to the Table
     *
     * @param string $caption
     * @access public
     * @return void
     **/
    
public function addCaption$caption ) {
        
$this->_html_string .= "<caption>$caption</caption>\n";
    }
    
    
/**
     * getRows
     * 
     * Gets the number of rows from the table
     *
     * @access public
     * @return integer
     **/
    
public function getRows() {
        return 
$this->_rows;
    }
    
    
/**
     * addBody
     * 
     * Adds a Body to a Table
     *
     * @param array $body_props
     * @access public
     * @return void
     **/
    
public function addBody$body_props = array() ) {
        if( 
$this->_tbody_open ) { 
            if( 
$this->_row_open ) { $this->closeRow(); }
            
$this->closeBody();
        }
        
        
$bprops $this->prop2String$body_props );
        
$this->_html_string.="\n<tbody$bprops>\n";
        
$this->_tbody_open true;
    }
    
    
/**
     * closeBody
     *
     * Closes a open Body (automatically called)
     *
     * @access private
     * @return void
     **/
    
private function closeBody() {
        
$this->_html_string.="\n</tbody>\n";
        
$this->_tbody_open false;
    }
    
    
/**
     * addRow
     *
     * Adds a new Row to the Table
     *
     * @param array $row_props
     * @access public
     * @return void
     **/
    
public function addRow$row_props = array() ) {
        if( 
$this->_row_open ) { $this->closeRow(); }
        
$rowprop $this->prop2String$row_props );
        
        
$this->_html_string.="<tr$rowprop>\n";
        
$this->_rows++;
        
$this->_row_open true;
    }
    
    
/**
     * closeRow
     *
     * Closes a Row
     *
     * @access private
     * @return void
     **/
    
private function closeRow() {
        
$this->_html_string.= "\n</tr>\n";
        
$this->_row_open false;
    }
    
    
/**
     * addHeader
     *
     * Adds a Table Header to the Table
     *
     * @param string $label
     * @param array $header_props
     * @access public
     * @return void
     **/
    
public function addHeader$label$header_props = array() ) {
        
$header_props $this->prop2String$header_props );
        
$th "\t<th$header_props>$label</th>\n";
        
$this->_html_string .= $th;
    }
    
    
/**
     * addCell
     *
     * Adds a new Cell to the Table
     *
     * @param string $text
     * @param array $cell_props
     * @access public
     * @return void
     **/
    
public function addCell$text '&nbsp;'$cell_props = array() ) {
        if( 
$this->_row_open === false ) { $this->addRow(); }
        
        
$cell_props $this->prop2String$cell_props );
        
$cell "\t<td$cell_props>$text</td>\n";
        
$this->_html_string .= $cell;
    }
    
    
/**
     * getOutput
     *
     * Returns the Table Output after construction
     *
     * @access public
     * @return string
     **/
    
public function getOutput() {
        if( 
$this->_row_open ) { $this->closeRow(); }
        if( 
$this->_tbody_open ) { $this->closeBody(); }
        
        
$str $this->_html_string;
        
$str.= "</table>\n";
        
        return 
$str;
    }
    
    public function 
__toString() {
        return 
$this->getOutput();
    }
}
  #3 (permalink)  
Antiguo 04/06/2007, 13:00
 
Fecha de Ingreso: mayo-2006
Mensajes: 124
Antigüedad: 17 años, 11 meses
Puntos: 0
Re: tabla html

Sino tendrias que leer algo sobre css
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:05.