Pero el problema que tengo es el siguiente.
En mi base de datos tengo una tabla llamada personas que tiene varios campos, nombre, apellido, numero tlf, email etc... mi instrucción mysql genera un pdf que me muestra todos los registros que están dentro de la tabla personas, pero... si yo solo quiero generar 1 registro como debo hacer.
Ejemplo:
Tabla personas
Registro 1 - Alberto Fulano de Tal 630489321 [email protected]
Registro 2 - Juan Carlos Fulano de Tla 643845930 [email protected]
Registro 3 ......
Registro 4 ......
Registro 5 ......
Con lo que tengo montado me generaría un pdf con los 5 registros y todos sus datos de cada campo
Si yo quiero generar un pdf que me extraiga solo el registro 1 o solo el registro 4 como tendría que hacer?. Llevo varios dias probando y soy incapaz
Os dejo el código:
Código PHP:
<?php
// test the table functions
error_reporting(E_ALL);
include('class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('./fonts/Helvetica');
//--------------------------------------------------
// you will have to change these to your settings
$host = 'localhost';
$user = 'root';
$password = '';
$database = 'bd_contactos';
$query = 'select cod_nme,cod_aplds,txt_tlfno_trbllo from persoas';
//--------------------------------------------------
// open the connection to the db server
$link = mysql_connect($host,$user,$password);
// change to the right database
mysql_select_db($database);
// initialize the array
$data = array();
// do the SQL query
$result = mysql_query($query);
// step through the result set, populating the array, note that this could also have been written:
// while($data[] = mysql_fetch_assoc($result)) {}
while($data[] = mysql_fetch_array($result, MYSQL_ASSOC)) {}
// make the table
$pdf->ezTable($data);
// do the output, this is my standard testing output code, adding ?d=1
// to the url puts the pdf code to the screen in raw form, good for checking
// for parse errors before you actually try to generate the pdf file.
if (isset($d) && $d){
$pdfcode = $pdf->output(1);
$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
echo '<html><body>';
echo trim($pdfcode);
echo '</body></html>';
} else {
$pdf->stream();
}
?>