elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Tablas multiceldas/multicell con php, mysql y libreria FPDF
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Tablas multiceldas/multicell con php, mysql y libreria FPDF  (Leído 4,929 veces)
ontte

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Tablas multiceldas/multicell con php, mysql y libreria FPDF
« en: 15 Mayo 2013, 04:06 am »

Hola, soy nuevo en este foro, el tema es ese..multiceldas con la libreria fpdf, php y mysql..
Tengo este código pero quisiera implementarle las multiceldas a la tabla con "multicell" en vez de "cell", no sé exactamente como agregarlas, espero que me puedan ayudar y gracias de antemano.

Aquí el código:

<?php
require('fpdf.php');

class PDF_MySQL_Table extends FPDF
{
var $ProcessingTable=false;
var $aCols=array();
var $TableX;

function TableHeader()
{
   $this->SetFont('Arial','B',10);
   $this->SetX($this->TableX);
   $fill=!empty($this->HeaderColor);
   if($fill)
      $this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]);
   foreach($this->aCols as $col)
      $this->Cell($col['w'],6,$col['c'],1,0,'C',$fill);
   $this->Ln();
}

function Row($data) //Aqui se muestra la información de la tabla
{
   $this->SetX($this->TableX);
   $x=$this->GetX();
    $y=$this->GetY();
   foreach($this->aCols as $col)
      $this->Cell($col['w'],5,$data[$col['f']],1,$col['a'],false);
   $this->Ln();
}

function CalcWidths($width,$align)
{
   //Compute the widths of the columns
   $TableWidth=0;
   foreach($this->aCols as $i=>$col)
   {
      $w=$col['w'];
      if($w==-1)
         $w=$width/count($this->aCols);
      elseif(substr($w,-1)=='%')
         $w=$w/100*$width;
      $this->aCols[$i]['w']=$w;
      $TableWidth+=$w;
   }
   //Compute the abscissa of the table
   if($align=='C')
      $this->TableX=max(($this->w-$TableWidth)/2,0);
   elseif($align=='R')
      $this->TableX=max($this->w-$this->rMargin-$TableWidth,0);
   else
      $this->TableX=$this->lMargin;
}

function AddCol($field=-1,$width=-1,$caption='',$align='L')
{
   //Add a column to the table
   if($field==-1)
      $field=count($this->aCols);
   $this->aCols[]=array('f'=>$field,'c'=>$caption,'w'=>$width,'a'=>$align);
}

function Table($query,$prop=array())
{
   //Issue query
   $res=mysql_query($query) or die('Error: '.mysql_error()."<BR>Query: $query");
   //Add all columns if none was specified
   if(count($this->aCols)==0)
   {
      $nb=mysql_num_fields($res);
      for($i=0;$i<$nb;$i++)
         $this->AddCol();
   }
   //Retrieve column names when not specified
   foreach($this->aCols as $i=>$col)
   {
      if($col['c']=='')
      {
         if(is_string($col['f']))
            $this->aCols[$i]['c']=ucfirst($col['f']);
         else
            $this->aCols[$i]['c']=ucfirst(mysql_field_name($res,$col['f']));
      }
   }
   //Handle properties
   if(!isset($prop['width']))
      $prop['width']=0;
   if($prop['width']==0)
      $prop['width']=$this->w-$this->lMargin-$this->rMargin;
   if(!isset($prop['align']))
      $prop['align']='C';
   if(!isset($prop['padding']))
      $prop['padding']=$this->cMargin;
   $cMargin=$this->cMargin;
   $this->cMargin=$prop['padding'];
   //Compute column widths
   $this->CalcWidths($prop['width'],$prop['align']);
   //Print header
   $this->TableHeader();
   //Print rows
   $this->SetFont('Arial','',9);
   $this->ColorIndex=0;
   $this->ProcessingTable=true;
   while($row=mysql_fetch_array($res))
      $this->Row($row);
   $this->ProcessingTable=false;
   $this->cMargin=$cMargin;
   $this->aCols=array();
}
}
?>


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Su version de Librería PHP MySQL 5.0.51a es distinta de... Servidor MySQL 6.0.5
PHP
SpiderNet 2 12,773 Último mensaje 30 Julio 2008, 03:32 am
por SpiderNet
php,mysql y tablas
PHP
Zieg Uchiha 3 2,742 Último mensaje 4 Marzo 2009, 19:01 pm
por Zieg Uchiha
PHP VERSION 5.2.13 CON LIBRERÍA FPDF
PHP
Ensy 0 2,171 Último mensaje 7 Mayo 2010, 14:09 pm
por Ensy
distintas cabeceras pdf libreria fpdf
PHP
OssoH 2 4,052 Último mensaje 14 Octubre 2010, 21:42 pm
por ~ Yoya ~
crear codigo QR en pdf usando libreria fpdf
PHP
OssoH 5 22,491 Último mensaje 8 Septiembre 2023, 04:19 am
por OCramxD1
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines