![Curso de PHP🐘 y MySql🐬 [91.- Imprimir datos de MySQL con DomPDF] 1 php91](https://www.programadornovato.com/wp-content/uploads/2020/06/php91-535x251.jpg)
Curso de PHP🐘 y MySql🐬 [91.- Imprimir datos de MySQL con DomPDF]
En este tutorial vamos a imprimir los datos de alguno de nuestros productos que están en mysql con DomPDF con PHP.
Codigo: https://github.com/programadornovato/php/commit/343e5ada48626fb3792e97b9405f52c2018ccaf2
<?php
include_once "db_empresa.php";
$con=mysqli_connect($db_host,$db_user,$db_pass,$db_database);
$query="SELECT nombre,precioVenta,categoria from productos where id=".$_GET['id'].";";
$res=mysqli_query($con,$query);
$row=mysqli_fetch_assoc($res);
if($row){
?>
<style>
table{
width: 100%;
border: 1px;
}
td,th{
width: 33%;
border: 1px solid #000;
}
thead{
font-weight: bold;
text-align: center;
}
</style>
<table cellspacing="0">
<thead>
<tr>
<th colspan="3" >Productos</th>
</tr>
<tr>
<th>Nombre</th>
<th>Precio de venta</th>
<th>Categoria</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $row['nombre'] ?></td>
<td><?php echo $row['precioVenta'] ?></td>
<td><?php echo $row['categoria'] ?></td>
</tr>
</tbody>
</table>
<?php
}else{
echo "No hay datos";
}
?>
<?php
use Dompdf\Dompdf;
include_once "dompdf/autoload.inc.php";
$pdf=new Dompdf();
$html=file_get_contents("http://localhost/php/producto.php?id=2");
$pdf->loadHtml($html);
$pdf->setPaper("A7","landingpage");
$pdf->render();
$pdf->stream();
🔗 Descargar domPDF: https://github.com/dompdf/dompdf/releases
🎦 Esta lista de reproducción: https://www.youtube.com/playlist?list=PLCTD_CpMeEKS2Dvb-WNrAuDAXObB8GzJ0
Codigos en gdrive: https://drive.google.com/file/d/1tQwYvfL2jiUFc6beTWkOkGmXkq5zzFw2/view?usp=sharing
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true
🔗 Facebook: https://facebook.com/ProgramadorNovatoOficial
🔗 Twitter: https://twitter.com/programadornova
🔗 Linkedin: https://www.linkedin.com/in/programadornovato/
🔗 Instagram: https://www.instagram.com/programadornovato/
Ave que vuela, a la cazuela.