Foros del Web » Programando para Internet » PHP »

PHP OO No muestra el 1 registro en un pdf

Estas en el tema de No muestra el 1 registro en un pdf en el foro de PHP en Foros del Web. HOLA MI PROBLEMA ES EL SIGUIENTE....ESTOY GENERANDO UN ARCHIVO PDF PERO AL MOMENTO DE MOSTRAR LOS REGISTROS DE LA BASE DE DATOS NO ME MUESTRA ...
  #1 (permalink)  
Antiguo 26/10/2011, 18:16
Avatar de adi_16_17  
Fecha de Ingreso: octubre-2011
Ubicación: jalisco
Mensajes: 8
Antigüedad: 12 años, 6 meses
Puntos: 0
Pregunta No muestra el 1 registro en un pdf

HOLA MI PROBLEMA ES EL SIGUIENTE....ESTOY GENERANDO UN ARCHIVO PDF PERO AL MOMENTO DE MOSTRAR LOS REGISTROS DE LA BASE DE DATOS NO ME MUESTRA EL PRIMER REGISTRO.....ES DECIR, ME MUESTRA DEL 2 REGISTRO EN ADELANTE....

OJALA ME PUEDAN AYUDAR

....GRACIAS POR SU AYUDA...


.................................................. .................................................. .....................


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

class PDF extends FPDF
{
function Header(){
// Logo
$this->Image('udg.gif',30,10,20,23);
$this->Ln(10);
$this->SetFont('Arial','B',13);
$this->Cell(100);
// Título
$this->Cell(30,7,'Historial de Abonos Registrados',0,1,'C');
$this->Cell(100);
$this->Ln(10);
}

// Pie de página
function Footer(){
$week_days = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
$monts = array("","Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$week_days_now = date("w");
$day_now = date("d");
$mont_now = date("n");
$year_now = date("Y");
$hora = date("H:i:s");
$date = $week_days[$week_days_now].", ".$day_now . " " ." de ".$monts[$mont_now]." de ".$year_now." - ".$hora;
$this->SetY(-12);
$this->SetFont('Arial','I',8);
// Número de página
$this->Cell(0,10,'Pagina '.$this->PageNo().' de {nb}'.' '.$date,0,0,'C');
}

//Tabla coloreada
function FancyTable($encabezados,$result)
{
//Colores, ancho de línea y fuente en negrita
$this->Cell(20);
$this->SetFillColor(62,102,60);
$this->SetTextColor(255);
$this->SetDrawColor(0,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','I');
//Cabecera
$w=array(50,20,35,30,33,30);
for($i=0;$i<count($encabezados);$i++)
$this->Cell($w[$i],7,$encabezados[$i],1,0,'C',1);
$this->Ln();
//Restauración de colores y fuentes
$this->SetFillColor(244,244,244);
$this->SetTextColor(0);
$this->SetFont('');
//Datos
$fill=true;
$y=20;
while ($row = mysql_fetch_array($result)){
$this->Cell(20);
$this->Cell($w[0],10,$row[0],'LR',0,'C',$fill);
$this->Cell($w[1],10,$row[1],'LR',0,'C',$fill);
$this->Cell($w[2],10,$row[2],'LR',0,'C',$fill);
$this->Cell($w[3],10,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],10,$row[4],'LR',0,'C',$fill);
$this->Cell($w[5],10,$row[5],'LR',0,'C',$fill);

$this->Ln();
}
}
} //fin de la definicion de la clase extendida de fpdf

//----------------------------------------------------
$conexion=mysql_connect("localhost","root","");
mysql_select_db("zapateria",$conexion);;

$result = mysql_query("SELECT cliente.nombre,abonos.cliente,abonos.fecha,abonos. saldo_debe,abonos.cant_abono,abonos.saldo_actual FROM abonos, cliente where abonos.cliente=cliente.id_cliente order by abonos.cliente,abonos.fecha", $conexion);

if ($row = mysql_fetch_array($result))
{
$pdf=new PDF('L','mm','Letter');
$pdf->AliasNbPages();
//Titulos de las columnas
$encabezados=array('Nombre','Codigo','Fecha','Sald o Total','Saldo Abonado','Saldo Actual');
$pdf->SetFont('Arial','',12);
$pdf->AddPage();
$pdf->FancyTable($encabezados,$result); //dibuja la tabla con la funcion FancyTable

$pdf->Output();
}
else
{
echo "¡ La base de datos está vacia !";
}
?>
  #2 (permalink)  
Antiguo 26/10/2011, 18:22
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: No muestra el 1 registro en un pdf

Es completamente normal, pues en el siguiente código:
Código PHP:
if ($row mysql_fetch_array($result)) 
Con la instrucción mysql_fetch_array() ya estás recorriendo el puntero una posición, por ende, las siguientes veces que ejecutas dicha instrucción en tu bucle que arma la tabla el primer registro ya no está presente.

Simplemente esta mal esa linea que haces, esa no es la forma correcta de comprobar los registros.

Debes cambiarla por algo así:
Código PHP:
if (mysql_num_rows($result)) 
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 26/10/2011, 18:28
Avatar de adi_16_17  
Fecha de Ingreso: octubre-2011
Ubicación: jalisco
Mensajes: 8
Antigüedad: 12 años, 6 meses
Puntos: 0
Respuesta: No muestra el 1 registro en un pdf

pateketrueke...........muchisisisisisisisimas graciassssssssssssssss.........!!!!!!!!.......

..............ME FUNCIONO MUY BIEN...!!!.....


GRACIASSSSSSSSSSSSSSSSSSS....!!!....:D

Etiquetas: muestra, mysql, pdf, registro, sql, tabla
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 22:15.