Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/12/2012, 08:15
carlos_alberto411
 
Fecha de Ingreso: noviembre-2012
Mensajes: 12
Antigüedad: 11 años, 5 meses
Puntos: 0
Respuesta: Codigo php para generar un pdf

Cita:
Iniciado por nahuelevy Ver Mensaje
sino, copiame el codigo que quieras convertir a pdf y te ayudo!
Hola Aqui te envio lo que tengo consta de un html y un php


Este es el html que te permite la búsqueda de los equipos por filtros si se desea hacer una búsqueda mas exacta o una búsqueda completa en este caso
Código HTML:
Ver original
  1. <script language="javascript"  type="Text/javascript">
  2. function validando(busc){
  3.    if(busc.status.value == ''){
  4.     alert('No se puede realizar la busqueda sin algun dato');
  5.     busc.status.focus();
  6.     return false;
  7.   }
  8.     return true;
  9. }
  10.  </script>
  11. </head>
  12. <body background='imagenes\portada.jpg'>
  13. <a href="principal.html"><img src='imagenes\atras.jpg'align="left" width=70 height=70></a> 
  14. <br><br>
  15. <br><br>
  16. <br><br>
  17. <br><br>
  18. <br><br>
  19.     <table id='miTabla' align='center' border="0"  width="348" height="200">
  20.         <tr width='50%'bgcolor='00A3C2'>
  21.             <td height='10%'>
  22.                 <p align='center'><font color='FFFFFF' size='5'>Listado de equipos</p>
  23.             </td>
  24.         </tr>
  25.         <tr bgcolor='LightBlue' width='50%'>
  26.             <td height='90%'>
  27.        
  28.         <table align='center' border='0'>
  29.         <tr bgcolor='00A3C2'>  
  30.                 <form action="buscarequipo.php" method="post" align='center' name='busc' onsubmit="return validando(this)">
  31.                     <p align='center'><font size='4' color='darkblue'>Criterio de Busqueda:<br>
  32.                     <select name="opcion" >
  33.                         <option value="todas">------</option>
  34.                         <option value="marca">Marca</option>
  35.                         <option value="departamento">Departamento</option>
  36.                         <option value="ip">IP</option>
  37.                         <option value="status">Status</option>
  38.                     </select><br>
  39.                     <input type='text' name='cadena'><td>
  40.                     <input type="submit" value="Buscar" align='center'>
  41.                     </td>
  42.                 </form>
  43.             </td>
  44.         </tr>
  45.     </table>
  46.     </table>
  47. </body>
  48. </html>

Este es el php que trae los equipos registrados en la BD dependiendo de la búsqueda que hace el pasa por el ciclo y traer los datos requeridos

Código PHP:
Ver original
  1. <html>
  2.  
  3. <body background='imagenes\portada.jpg'>
  4. <h2 align=center><font color='darkblue' size='6'>Consulta</font> </h3>
  5. <h3 align=center> <font color='darkblue' size='5'> Los datos son solicitados son: </font> </h3>
  6.  
  7. <br><br>
  8. <br><br>
  9. <br><br>
  10.  
  11. <table border='1' align='center'>
  12.         <tr bgcolor="00A3C2" >
  13.              <td><font color='FFFFFF' size='3'>Serial </font> </td>
  14.              <td><font color='FFFFFF' size='3'>Marca del equipo</p></td>
  15.              <td><font color='FFFFFF' size='3'>Modelo del equipo</p></td>
  16.              <td><font color='FFFFFF' size='3'>Memoria Interna del equipo</p></td>
  17.              <td><font color='FFFFFF' size='3'>Memoria Ram del equipo</p></td>
  18.              <td><font color='FFFFFF' size='3'>Procesador del equipo</p></td>
  19.              <td><font color='FFFFFF' size='3'>Sistema operativo del equipo</p></td>
  20.              <td><font color='FFFFFF' size='3'>Dirección IP</p></td>
  21.              <td><font color='FFFFFF' size='3'>Usuario a cargo del equipo</p></td>
  22.              <td><font color='FFFFFF' size='3'>Departamento</p></td>
  23.              <td><font color='FFFFFF' size='3'>Status</p></td>
  24.           </tr>
  25. <tr>
  26. </tr>
  27. <tr>
  28. </tr>
  29.  
  30.  
  31. <?php
  32.  
  33.     $opcion=$_POST['opcion'];
  34.     $cadena=$_POST['cadena'];
  35.    
  36.            $cnn = @mysql_connect("localhost","root","");
  37.            if (!$cnn) {
  38.               echo("<p>No es Posible Establecer Conexión con el Servidor.</p>");
  39.               exit();
  40.            }     
  41.            if (!@mysql_select_db("universitas",$cnn)){
  42.               echo("<p>No es Posible Establecer Conectar con la Base de Datos.</p>");
  43.               exit();
  44.            }                   
  45.            if ($opcion == 'marca'){        
  46.            $consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where marca='$cadena';");
  47.            }
  48.            if ($opcion == 'departamento'){         
  49.            $consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where departamento='$cadena';");
  50.            }
  51.            if ($opcion == 'ip'){           
  52.            $consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where ip='$cadena';");
  53.            }
  54.            if ($opcion == 'status'){           
  55.            $consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where status='$cadena';");
  56.            }
  57.            if ($opcion == 'todas'){        
  58.            $consulta= @mysql_query("SELECT * FROM equipos;");
  59.            }
  60.            if (!$consulta) {       
  61.               echo("<p>Error al ejecutar el Query Sql.</p>");
  62.               exit();
  63.            }   
  64.        
  65.        $Registros=mysql_num_rows($consulta);           
  66.         while($Fila = mysql_fetch_array($consulta)) {
  67.                 echo "<tr bgcolor='LightBlue'>";
  68.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["serial"]."</td>";
  69.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["marca"]."</td>";
  70.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["modelo"]."</td>";
  71.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["minterna"]."</td>";
  72.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["mram"]."</td>";
  73.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["procesador"]."</td>";
  74.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["soperativo"]."</td>";
  75.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["ip"]."</td>";
  76.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["usuario"]."</td>";
  77.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["departamento"]."</td>";
  78.                 echo "<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["status"]."</td>";
  79.                
  80.                 echo "</tr>";          
  81.                
  82.            }
  83.            echo "</table><br>";
  84.            echo "<p style='color: #000000; font-weight: bold; font-size:9pt;'>Total Coincidencias : $Registros";
  85.          
  86.            echo"<p align='center'> <a href=buscarequipo.html> <img src='imagenes\atras.jpg' align='center' width=50 height=50><br>
  87.         <a href=principal.html> <p align='center'>¡Regresar al la pagina principal!</p></a>";
  88.            ?>
  89.         </td>
  90.       </tr>  
  91. </table>
  92. <?php
  93. ?>
  94. </body>
  95. </html>

mi idea era que cuando el php me traiga los datos de la BD tenga una opcion (Boton o link) que diga Imprimir Reporte y me imprima lo que me esta mostrando por pantalla no se si me explico bien pero POR FAVOR necesito tu ayuda mi trabajo de grado depende de esto