11/12/2012, 13:06
|
| | Fecha de Ingreso: noviembre-2012
Mensajes: 12
Antigüedad: 12 años, 2 meses Puntos: 0 | |
Respuesta: Codigo php para generar un pdf Cita:
Iniciado por nahuelevy En realidad, lo único que debes cambiar es agregar un boton que llame a otro PHP que convierta a PDF. Ese php se vería algo así Código PHP: <?
require_once("dompdf/dompdf_config.inc.php");
$html="<html>
<h2 align=center><font color='darkblue' size='6'>Consulta</font> </h3>
<h3 align=center> <font color='darkblue' size='5'> Los datos son solicitados son: </font> </h3>
<br><br>
<br><br>
<br><br>
<table border='1' align='center'>
<tr bgcolor='00A3C2' >
<td><font color='FFFFFF' size='3'>Serial </font> </td>
<td><font color='FFFFFF' size='3'>Marca del equipo</p></td>
<td><font color='FFFFFF' size='3'>Modelo del equipo</p></td>
<td><font color='FFFFFF' size='3'>Memoria Interna del equipo</p></td>
<td><font color='FFFFFF' size='3'>Memoria Ram del equipo</p></td>
<td><font color='FFFFFF' size='3'>Procesador del equipo</p></td>
<td><font color='FFFFFF' size='3'>Sistema operativo del equipo</p></td>
<td><font color='FFFFFF' size='3'>Dirección IP</p></td>
<td><font color='FFFFFF' size='3'>Usuario a cargo del equipo</p></td>
<td><font color='FFFFFF' size='3'>Departamento</p></td>
<td><font color='FFFFFF' size='3'>Status</p></td>
</tr>
<tr>
</tr>
<tr>
</tr>";
$opcion=$_POST['opcion'];
$cadena=$_POST['cadena'];
$cnn = @mysql_connect("localhost","root","");
if (!$cnn) {
echo("<p>No es Posible Establecer Conexión con el Servidor.</p>");
exit();
}
if (!@mysql_select_db("universitas",$cnn)){
echo("<p>No es Posible Establecer Conectar con la Base de Datos.</p>");
exit();
}
if ($opcion == 'marca'){
$consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where marca='$cadena';");
}
if ($opcion == 'departamento'){
$consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where departamento='$cadena';");
}
if ($opcion == 'ip'){
$consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where ip='$cadena';");
}
if ($opcion == 'status'){
$consulta= @mysql_query("SELECT serial, marca, modelo, minterna, mram, procesador, soperativo, ip, usuario, departamento, status FROM equipos where status='$cadena';");
}
if ($opcion == 'todas'){
$consulta= @mysql_query("SELECT * FROM equipos;");
}
if (!$consulta) {
echo("<p>Error al ejecutar el Query Sql.</p>");
exit();
}
$Registros=mysql_num_rows($consulta);
while($Fila = mysql_fetch_array($consulta)) {
$html.= "<tr bgcolor='LightBlue'>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["serial"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["marca"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["modelo"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["minterna"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["mram"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["procesador"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["soperativo"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["ip"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["usuario"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["departamento"]."</td>
<td align='center' style='color: #000000; font-weight: bold;'>".$Fila["status"]."</td>
</tr>";
}
$html.="</table><br>
<p style='color: #000000; font-weight: bold; font-size:9pt;'>Total Coincidencias : $Registros";
$html.="</td>
</tr>
</table>";
mysql_close($cnn);
$html.="</body>
</html>";
//convierto el resultado a pDF
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("resultados.pdf");
?> Esto debería funcionar! Saludos y contame como te fue
Hola man soy yo aun tengo dudas no e logrado hacer eso veras no entiendo esta parte
Código PHP:
Ver original//convierto el resultado a pDF $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $dompdf->stream("resultados.pdf");
hay dice que me enviada un resultado.pfd pero no hace nada yo cree un boton y no me hace pero nada :( |