0
I made the code to show only if you have image, but it also shows the body of empty, it says in the source code of the page that my PHP is a comment as shown in the image below.
And the code is this:
How do I not show the empty pictures the way you are here?
echo '
<php
$seleciona = mysqli_query($conexao, "SELECT * FROM postagem where status=1 ORDER BY id desc");
while($campo=mysqli_fetch_array($seleciona)){
$nome_imagem = $campo["nome_imagem"];
?>
<center>
<div id="panel" align="left">
<label class="titulo"> '. $result1[$i][1] . '</label><br>
<p class="descricao">'. $result1[$i][2] . '</p><br>
<?php if ($nome_imagem != null){?><p><img src="foto/'. $result1[$i][3] . '" class="foto"></p><?php } ?>
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Postado por: '. $result1[$i][6] . ' em '. $result1[$i][4] . ' às '. $result1[$i][5] . '</td>
<a href="0_excluir_postagem.php?editaid='. $result1[$i][0] . '"><span class="glyphicon glyphicon-trash"></span></a>
</div></center>
<?php }?>
</div>' ;
}
The syntax is wrong, remove this echo ' at the beginning, for the image, use the function is_file()
– Victor M.
But it’s inside a FOR: for ($i = 0; $i < Count($result1); $i++) { #Coding }
– Alison Walker
Tries
$nome_imagem != ""
– Sam