Código:
  
Las instrucciones que uso para recuperar los datos de la base de datos son:Warning: Invalid argument supplied for foreach() in c:\servidor\web\soft\socio\generar.php on line 75 Warning: Cannot modify header information - headers already sent by (output started at c:\servidor\web\soft\socio\generar.php:75) in c:\servidor\web\soft\socio\fpdf.php on line 1022 FPDF error: Some data has already been output to browser, can't send PDF file
Código:
  
La función FancyTable que uso es:
$pdf=new PDF();
$pdf->AddPage();
//$pdf->SetFont('Times','B',16);
$bd = mysql_connect('localhost', 'root', '');
if (!$bd)  {
  echo "Error, no puede encontrarse a la base de datos";
  exit;
}
mysql_select_db('soft');
$query = "SELECT nombre FROM categoria";
$resultado = mysql_query($query);
$num_filas = mysql_num_rows($resultado);
$i=0;
$precio_tot=0;
$cabecera=array('Categoria','Producto','Precio');
while($categoria=mysql_fetch_assoc($resultado)){
	$id_producto[$i]=$_POST[$categoria["nombre"]];
	$query1 = "SELECT nombre,precio FROM producto where codigo='".$id_producto[$i]."'";
	$res = mysql_query($query1);
	$datos_producto=mysql_fetch_assoc($res);
	if($id_producto[$i]!=0){
	//for($j=0;$j<count($cabecera);$j++){
		$matriz[$i][0]=$categoria["nombre"];
		$matriz[$i][1]=$datos_producto["nombre"];
		$matriz[$i][2]=$datos_producto["precio"];
//	}//
	$precio_tot+=$matriz[$i][2];
	}
	$i++;
	
}
//$pdf->FancyTable($cabecera,$matriz);
$pdf->Ln(20);
//$pdf->SetXY(45,70);
$pdf->FancyTable($cabecera,$matriz,$precio_tot);
$pdf->Cell(0,15,"Total: "."$precio_tot");
$pdf->Output();
Código:
  
El error del espacio en blanco me sale en categoria, pero no logro saber porque puede ser...//Tabla coloreada
function FancyTable($header,$data,$precio_tot)
{
    //Colores, ancho de línea y fuente en negrita
    $this->SetFillColor(255,0,0);
    $this->SetTextColor(255);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	
    //Cabecera
	$this->SetXY(45,70);
	$this->SetFont('Times','B',16);
    $w=array(40,35,40);
    for($i=0;$i<count($header);$i++)
        $this->Cell($w[$i],7,$header[$i],1,0,'C',1);
    $this->Ln();
    //Restauración de colores y fuentes
    $this->SetFillColor(224,235,255);
    $this->SetTextColor(0);
    $this->SetFont('');
    //Datos
	$this->SetFont('Times','B',8);
	$this->SetXY(45,76);
	$x=45;
	$y=76;
    $fill=0;
    foreach($data as $row)
    {	
        $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
        $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
        $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);
        //$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);
        $this->Ln();
        $fill=!$fill;
		$this->SetXY($x,$y+=6);
    }
	$this->Cell(array_sum($w),0,'','T');
	$this->SetXY($x+101,$y);
	//$this->Cell(0,15,"Total:",'$precio_tot');
	
    //$this->Cell(array_sum($w),0,'','T');
	
}
Gracias!!!!
 
 
 
 
