0
In the code below, I intended to place an image inside the table displayed in PDF, but the image is not displayed and a box with "X"
red. As I put the image "inside" the mysqli_fetch_assoc
?
In the current code only appear images outside the while
. There are some different image paths, because I’m testing - unsuccessfully - all possible paths.
Here’s the code:
<?php
include ('pdf/mpdf.php');
include('config.php'); session_start();
$id=$_SESSION['id'];
$tabela = '<img src=/bimbopnl/logo.png />';
$tabela .= '<br><br><br><br><br><br>';
$tabela .= '<table align=left>';
$tabela .= '<tr>';
$tabela .= '<td colspan="4" align="center"><br>Indicadores<br><br>
</tr>';
$tabela .= '</tr>';
$tabela .= '<tr>';
$tabela .= '<td><b> Indicador </b></td>';
$tabela .= '<td><b> Valor </b></td>';
$tabela .= '<td><b> Meta </b></td>';
$tabela .= '<td><b> Otimismo </b></td>';
$tabela .= '</tr>';
$sql = mysqli_query($conexao,"SELECT * FROM tb_indicadores where id='$id' and dataIndicador='FEV - 2018' and tipoIndicador=1") or die(mysql_error());
while($dados = mysqli_fetch_assoc($sql))
{
$tabela .= '<tr>';
$id=$dados['id'];
$nome=$dados['nomeindicador'];
$idind = $dados['idIndicador'];
$meta = $dados['meta'];
$otimismo = $dados['otimismo'];
$dif = $valor/$meta;
imagem='';
if($valor==''){$imagem= '/bimbopnl/imagens/semvalor.png';}
if(($otimismo=='otimista')&&($dif<=0.95)){$imagem= '/miniredup.png';}
if(($otimismo=='pessimista')&&($dif<=0.95)){$imagem= 'bimbopnl/minireddown.png';}
if(($otimismo=='otimista')&&($dif>0.9 && $dif<=0.95)){$imagem= 'bimbopnl/miniyellowup.png';}
if(($otimismo=='pessimista')&&($dif>0.9 && $dif<=0.95)){$imagem= 'bimbopnl/miniyellowdown.png';}
if(($otimismo=='otimista')&&($dif>0.95 && $dif<=1.05)){$imagem= 'bimbopnl/minigreenup.png';}
if(($otimismo=='pessimista')&&($dif>0.95 && $dif<=1.05)){$imagem= 'bimbopnl/minigreendown.png';}
if(($otimismo=='otimista')&&($dif>1.05)){$imagem= 'bimbopnl/miniblueup.png';}
if(($otimismo=='pessimista')&&($dif>1.05)){$imagem= 'bimbopnl/minibluedown.png';}
$tabela .= '<td>'.$dados['nomeindicador'].'</td>'; $tabela .= '<td>'.$dados['valorIndicador'].'</td>';
$tabela .= '<td>'.$dados['meta'].'</td>'; $tabela .= '<img src=/'.'"$imagem"'.'>';
$tabela .= '</tr>';
}
$tabela .= '</table>';
$tabela .= '<img src=/bimbopnl/rent.png>';
echo '<br>'; echo '<br>'; echo '<br>';
$arquivo = 'Cadastro01.pdf';
$mpdf = new mPDF();
$mpdf->WriteHTML($tabela);
$mpdf->Output($arquivo, 'I');
?>
I’m using the class MPDF to produce a pdf.
Hello Maicon. Thank you for the strength!
– Pablo Henrique
Errors have appeared concerning some files I do not have: Warning: include(../mpdf60/mpdf.php): failed to open stream: No such file or directory in C: xampp htdocs bimbopnl pdffev.php on line 121 Warning: include(): Failed Opening '.. /mpdf60/mpdf.php' for inclusion (include_path='C: xampp php PEAR') in C: xampp htdocs bimbopnl pdffev.php on line 121 Warning: fopen(../VOUCHERS/.pdf): failed to open stream: No such file or directory in C: xampp htdocs bimbopnl pdf mpdf.php line on 7485 mPDF error: Unable to create output file: .. /VOUCHERS/. pdf
– Pablo Henrique
I went to the origin of the class but did not find tb on the site :(
– Pablo Henrique