2
Basically I have 3 tables , I’m making a kind of Inner Join in php kk and generating a new table with the data I want ,has how to turn this table into pdf ?
`
<table>
<th>Nome do Aluno</th>
<th>Nome do Curso</th>
<th>Nome do Professor</th>
<?php
$con=mysqli_connect("localhost","root","36398020","flex");
$a=mysqli_query($con,"select count(*) from ALUNO");
$res=mysqli_fetch_array($a);
echo $res[0];
$f=$res[0];
$f+=10;
$nomeAluno=array();
$alunoCursoId=array();
$nomeCurso=array();
$nomeProfessor=array();
for($a=0;$a<=$f;$a++){
$sql=mysqli_query($con,"select NOME_ALUNO from ALUNO where ID_ALUNO=$a;");
$n=mysqli_fetch_array($sql);
$nome[$a]=$n[0];
$query=mysqli_query($con,"select ALUNO_CURSO_ID from ALUNO where ID_ALUNO=$a;");
$we=mysqli_fetch_array($query);
$alunoCursoId[$a]=$we[0];
$sql1=mysqli_query($con,"select NOME_CURSO from CURSO where ID_CURSO='$alunoCursoId[$a]';");
$n1=mysqli_fetch_array($sql1);
$nomeCurso[$a]=$n1[0];
$sql2=mysqli_query($con,"select NOME_PROFESSOR from PROFESSOR where ID_PROFESSOR='$alunoCursoId[$a]';");
$n2=mysqli_fetch_array($sql2);
$nomeProfessor[$a]=$n2[0];
echo $table="
<tr>
<td>$nome[$a]</td>
<td>$nomeCurso[$a]</td>
<td>$nomeProfessor[$a]</td>
<tr>
";
}
?>
</table>
<A href=pf.php>PDF</A>
</body>
<?php
echo $table;
?>
</html>
`
The link points to this code
`
<?php
$con=mysqli_connect
( "localhost","root","36398020","flex");
use Dompdf\Dompdf;
require_once'dompdf/autoload.inc.php';
$dompdf=new DOMPDF();
$html=file_get_contents(pdf.php);
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream(
" ".$html."",
array("attachment"=>false )
);
?>`
Inserts the code you already have. There are some libraries that do this.
– Andrei Coelho
I’m trying the dompdf but it ends in error
– Guilherme Carvalho
Put the code in the question and enter the errors that are displayed. Only then can someone help you.
– Andrei Coelho
Which error is produced?
– Andrei Coelho
The PDF simply does not open.
– Guilherme Carvalho