Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/10/2011, 10:58
Avatar de CesarHC
CesarHC
 
Fecha de Ingreso: junio-2011
Ubicación: localhost
Mensajes: 566
Antigüedad: 12 años, 10 meses
Puntos: 56
Dompdf y myssql

Hola a todos pues les cuento que me puse a probar uns libreias php a pdf en concreto la DOMPDF con MySQL y me he trancado XD, esto es la estructura que he hencontrado y estoy siguiendo.

Código PHP:
Ver original
  1. <?php
  2. require_once("dompdf_config.inc.php");
  3.  
  4. /*
  5. mysql_query...
  6. mysql_fetch...
  7. */
  8. $html = 'generated html...';
  9.  
  10. $dompdf = new DOMPDF();
  11. $dompdf->load_html($html);
  12. $dompdf->render();
  13. $dompdf->stream("/tmp/sample.pdf");
  14. /*
  15. Add mail to code to attach /tmp/sample.pdf to a email and send
  16. */
  17. ?>

El mio lo tengo asi.

Código PHP:
Ver original
  1. <?php
  2. require_once("../pdf/dompdf/dompdf_config.inc.php");
  3.  
  4. /*
  5. mysql_query...
  6. mysql_fetch...
  7. */
  8. $link = mysql_connect("localhost", "root","");
  9. mysql_select_db("reqcot", $link);  
  10. $result = mysql_query("SELECT * FROM prueba ", $link);
  11.  
  12. $html = 'Aqui he probado sin exito -_-';
  13.  
  14. $dompdf = new DOMPDF();
  15. $dompdf->load_html($html);
  16. $dompdf->render();
  17. $dompdf->stream("sample.pdf");
  18. /*
  19. Add mail to code to attach /tmp/sample.pdf to a email and send
  20. */
  21. ?>

En lo que me he trabado es que no se como meter este codigo en $html:

Código PHP:
Ver original
  1. if ($row = mysql_fetch_array($result)){
  2.  echo "<table width='200' border='1' align='center' >
  3.    <td align='center'>Nombre</td>
  4.    <td align='center'>Apellido</td>
  5.     \n";
  6.    
  7.    do {
  8.       echo "
  9.  <tr>
  10.    <td align='center'>".$row["nombre"]."</td>
  11.    <td align='center'>".$row["apellido"]."</td>
  12.     <td align='center'><form action='frmprueba.php' method='get'>
  13.         <input type='hidden' name='idprueba' value=".$row["idprueba"]." />
  14.          <input type='hidden' name='nombre' value=".$row["nombre"]." />
  15.          <input type='hidden' name='apellido' value=".$row["apellido"]." />
  16.        
  17. </form></td>
  18.  </tr>
  19.       ";
  20.    } while ($row = mysql_fetch_array($result));
  21.    echo "</table> \n";
  22. } else {
  23. echo "¡ No se ha encontrado ningún registro !";
  24. }

Les agradeceria que me pudieran orientar un poco gracias.
__________________
Solo la práctica no te traicionara ¡¡¡¡¡¡

Seguir el camino tu debes PHP The Right Way.