Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/06/2011, 09:51
Avatar de Nano_
Nano_
 
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: -Problema para recorrer consulta??

Saludos

Podría ser de la siguiente manera:

Código PHP:
Ver original
  1. <?php
  2. require_once('html2pdf/html2pdf.class.php');
  3. $html2pdf = new HTML2PDF('1', 'Letter', 'es', false, 'ISO-8859-15', array(0, 0, 0, 0));
  4. //conexion a la base
  5. $conexion = mysql_connect('localhost', 'root', '') or die("IMPOSIBLE CONECTARSE AL SERVIDOR");
  6. $base = mysql_select_db('aceros_anglo', $conexion) or die("IMPOSIBLE CONECTARSE A LA BASE");
  7. $c = "SELECT * FROM productos";
  8. $res = mysql_query($c);
  9. $filas = mysql_num_rows($res);
  10. if ($filas > 0) {
  11.     /*     * ****CABECERA***** *///
  12.     $html = "<table border='1' align='center'>
  13.            <tr>
  14.                <td bgcolor='DimGray'><font color= 'white'>Clave del producto</font></td>
  15.                <td bgcolor='DimGray'><font color= 'white'>Nombre del producto</font></td>
  16.                <td bgcolor='DimGray'><font color= 'white'>Existencias</font></td>
  17.            </tr>";
  18.  
  19.  
  20.     while ($row = mysql_fetch_array($res)) {
  21.         $nombre = $row['nombre'];
  22.         $idp = $row['idp'];
  23.         $existencia = $row['existencia'];
  24.         $html.="<tr>
  25.            <td bgcolor='#CCCCCC'><b>" . $idp . "</b></td>
  26.            <td bgcolor='#CCCCCC'><b>" . $nombre . "</b></td>
  27.            <td bgcolor='#CCCCCC'><b>" . $existencia . "</b></td>";
  28.  
  29.         $html.= "</tr>";
  30.     }
  31.     $html.= "</table>";
  32. }
  33. $html2pdf->WriteHTML($html);
  34. $html2pdf->Output('Nombre_de_tu_PDF.pdf', 'I');
  35. ?>
__________________
:.:Nano.:: @nano_hard - Retornando al foro