![Negacion](http://static.forosdelweb.com/fdwtheme/images/smilies/negacion.gif)
Código:
<?php require('../fpdf16/fpdf.php'); //Conexion a la bd include('connection.php'); //Crea un nuevo pdf //Crea un nuevo pdf $pdf=new FPDF(); //Disable automatic page break $pdf->SetAutoPageBreak(true); //Añade primera página $pdf->AddPage(); //seteo inicial de margenes y position axis pr pagina $y_axis_initial = 0; $x_axis = 10; $y_axis = 20; //imprime los titulos de columna para la pagina (quitar comentarios para activar) $pdf->SetFillColor(232,232,232); $pdf->SetFont('Arial','B',10); $pdf->SetY($y_axis_initial); //$pdf->Cell(30,6,'CODI',1,0,'L',1); $y_axis = $y_axis + $row_height; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_alumnos = "-1"; if (isset($_GET['idgrado'])) { $colname_alumnos = $_GET['idgrado']; } mysql_select_db($database_connection, $connection); $query_alumnos = sprintf("SELECT *FROM alumnos WHERE idgrado = %s ORDER BY ApellidoPaterno ASC", GetSQLValueString($colname_alumnos, "text")); $alumnos = mysql_query($query_alumnos, $connection) or die(mysql_error()); $row_alumnos = mysql_fetch_assoc($alumnos); $totalRows_alumno = mysql_num_rows($alumnos); mysql_select_db($database_connection, $connection); $query_grados = sprintf("SELECT * FROM grados WHERE idgrado = %s ", GetSQLValueString($colname_alumnos, "text")); $grados = mysql_query($query_grados, $connection) or die(mysql_error()); $row_grados = mysql_fetch_assoc($grados); $totalRows_grados = mysql_num_rows($grados); //inicializo el contador $i = 0; //Seto el maximo de filas por pagina $max = 25; //Seteo la altuira de la fila $row_height = 6; while($row =@mysql_fetch_array($alumnos)) { //Si la fila actual es la ultima, creo una nueva página e imprimo el titulo (quitar comentarios para activar) if ($i == $max) { $pdf->AddPage(); //print column titles for the current page //$pdf->SetY($y_axis_initial); //$pdf->SetX(25); //$pdf->Cell(30,6,'CODI',1,0,'L',1); //Go to next row $y_axis = $y_axis + $row_height; //Set $i variable to 0 (first row) $i = 0; } do { $CODI = $row['rfcalumno']; $NOMB = $row['Nombre']; $LIBRE = $row['ApellidoPaterno']; $LIB = $row['ApellidoMaterno']; $pdf->SetY($y_axis); $pdf->SetX($x_axis); $linea=$CODI." ".$NOMB." ".$LIBRE." ".$LIB; } while ($row =@mysql_fetch_array($alumnos)); $pdf->MultiCell(0,6,$linea,0,1,'L',10); //$pdf->MultiCell(30,6,$CODI,0,0,'L',0); //$pdf->MultiCell(90,6,$NOMB,0,0,'Ln',0); //$pdf->MultiCell(120,6,$LIBRE,0,0,'Ln',0); //Go to next row $y_axis = $y_axis + $row_height; $i = $i + 1; } //Create file $pdf->Output(); ?> <?php mysql_free_result($alumnos); mysql_free_result($grados); ?>