PHP - consulta en php

 
Vista:

consulta en php

Publicado por congas1983 (29 intervenciones) el 19/05/2008 23:31:14
Buenas Tardes

Amigo tengo un problema con una consulta que estoy generando de php a pdf

ESTE ES EL CODIGO

<?php session_start();
require('fpdf.php');
$cn=mysql_connect("localhost","root","")or die ("no se puede establecer la conexion");
mysql_select_db("sisbagir");
$result=mysql_query("select * from integrante order by escuadron");
$numfilas=mysql_num_rows($result);
if ($numfilas==0)
{
echo "NO HAY REGISTROS EN LA BASE DE DATOS";
echo "<meta HTTP-EQUIV="REFRESH" content="2; url=hinformes.php">";
}
else
while ($numfilas=mysql_fetch_array($result))
{
$usuario = $_SESSION["usuario"];
$cedula=$numfilas["cedula"];
$nombre=$numfilas["nombres"];
$fecha=$numfilas["fechanac"];
$edad=$numfilas["edad"];
$tel=$numfilas["telefono"];
$movil=$numfilas["movil"];
$dir=$numfilas["direccion"];
$bar=$numfilas["barrio"];
$rh=$numfilas["rh"];
$eps=$numfilas["eps"];
$ing=$numfilas["ingreso"];
$inst=$numfilas["institucion"];
$escua=$numfilas["escuadron"];
$sexo=$numfilas["sexo"];
$pdf=new FPDF();
$pdf->AddPage();
//Fields Name position
$Y_Fields_Name_position =18;
//Table position, under Fields Name
$Y_Table_Position =24;
//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(200,300,200);
//Bold Font for Field Name
$pdf->SetFont('Arial','',6);
$pdf->SetX(196);
$pdf->Cell(20,4,$usuario,0,0,'L',0);
$pdf->SetX(30);
$pdf->SetFillColor(200,300,200);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetX(42);
$pdf->Cell(125,6,' LISTADO DE INTEGRANTES DE LA BANDA ATANASIO GIRARDOT',1,0,'L',1);
$pdf->SetX(40);
$pdf->SetFillColor(232,300,232);
$pdf->SetFont('Arial','B',6);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(2);
$pdf->Cell(12,4,'CEDULA',1,0,'L',1);
$pdf->SetX(14);
$pdf->Cell(90,4,' NOMBRES COMPLETOS ',1,0,'L',1);
$pdf->SetX(44);
$pdf->Cell(50,4,'FECHA_N',1,0,'L',1);
$pdf->SetX(56);
$pdf->Cell(58,4,'EDAD',1,0,'L',1);
$pdf->SetX(64);
$pdf->Cell(50,4,' TELEFONO ',1,0,'L',1);
$pdf->SetX(81);
$pdf->Cell(50,4,' MOVIL ',1,0,'L',1);
$pdf->SetX(96);
$pdf->Cell(50,4,' DIRECCION ',1,0,'L',1);
$pdf->SetX(124);
$pdf->Cell(50,4,' BARRIO ',1,0,'L',1);
$pdf->SetX(146);
$pdf->Cell(30,4,' RH ',1,0,'L',1);
$pdf->SetX(153);
$pdf->Cell(30,4,' EPS ',1,0,'L',1);
$pdf->SetX(165);
$pdf->Cell(20,4,' INGRESO ',1,0,'L',1);
$pdf->SetX(177);
$pdf->Cell(16,4,'ESCUADRON ',1,0,'L',1);
$pdf->SetX(193);
$pdf->Cell(14,4,' SEXO',1,0,'l',1);
$pdf->SetX(1);
$pdf->Ln();
//Now show the 3 columns
$pdf->SetFont('Arial','B',6);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(2);
$pdf->MultiCell(12,4,$cedula,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(14);
$pdf->MultiCell(30,4,$nombre,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(44);
$pdf->MultiCell(37,4,$fecha,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(56);
$pdf->MultiCell(40,4, $edad,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(64);
$pdf->MultiCell(60,4,$tel,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(81);
$pdf->MultiCell(72,4,$movil,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(96);
$pdf->MultiCell(57,4,$dir,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(124);
$pdf->MultiCell(69,4,$bar,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(146);
$pdf->MultiCell(47,4,$rh,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(153);
$pdf->MultiCell(40,4,$eps,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(165);
$pdf->MultiCell(28,4,$ing,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(177);
$pdf->MultiCell(30,4,$escua,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(193);
$pdf->MultiCell(14,4,$sexo,1);
//Create lines (boxes) for each ROW (Product)
//If you don't use the following code, you don't create the lines separating each row
$i = 0;
$pdf->SetY($Y_Table_Position);
while ($i < $number_of_products)
{
$pdf->SetX(2);
$pdf->MultiCell(10,4,'',1);
$i = $i +1;
}
$MSG='ANDRES ALVAREZ';
$pdf->SetAuthor('ANDRES ALVAREZ');
$pdf->SetSubject('LISTADO GENERAL DE INTEGRANTES');
$pdf->Output();

}

//Convert the Total Price to a number with (.) for thousands, and (,) for decimals.
$total = number_format($total,',','.','.');
//Create a new PDF file

mysql_close();
?>


EL PROBLEMA ES QUE CUANDO SE EJECUTA ESTE CODIGO SOLO ME ESTA TRAYENDO EL ULTIMO REGISTRO INGRESADO A LA BASE DE DATOS, SABIENDO QUE HAY VARIOS REGISTROS Y SEGUN LA CONSULTA QUE SE HACE EN EL CODIGO ES PARA QUE TRAIGA TODOS LOS REGISTRO DE LA TABLA.

Y CUANDO MODIFICO EL REGISTRO, VUELVO Y HAGO LA CONSULTA Y ME TREA LOS DATOS DEL ULTIMO REGISTRO SIN LAS MODIFICACIONES, ME TOCA CERRAR LA SECCION Y VOLVER A INGRESAR PARA QUE MUESTRE LAS MODIFICACIONES

NO SE COMO PODRIA SOLUCIONAR ESTE PROBLEMA

GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:consulta en php

Publicado por Omar Yépez (224 intervenciones) el 20/05/2008 00:00:24
No es por nada pero la ayuda que te puedo dar es que utilices DomPDF. esta es un API para fpdf y ya te olvidas de ese poco de :

$pdf->SetY($Y_Table_Position);
$pdf->SetX(153);
$pdf->MultiCell(40,4,$eps,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(165);
$pdf->MultiCell(28,4,$ing,1);

Solo creas tu pagina como en html y le dices a DomPDF que esa es la pagina que quieres pasar a pdf.

Es demasiado buena.

http://www.digitaljunkies.ca/dompdf/

Espero cambies y te sirva.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:consulta en php

Publicado por congas1983 (29 intervenciones) el 20/05/2008 17:20:24
amigo

que pena yo con el tema de libreria nunca he trabajado,

ya descargue el dompdf, estos archivos donde los meto dentro del php y como es el llamado dentro de la pagina php que quiero, convertir a pdf

gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar