基本上,这是一个元素,它显示来自数据库路径的图像。但是我只是无法使其工作。
<img class="img-circle profile_img" id="blah" src=" <?php $query2=mysqli_query($conexao,"select * FROM esc_usuarios_fotos WHERE img_usu_codigo = '" . $_SESSION['codigo'] . "'");
while($row2=mysqli_fetch_array($query2)){
if ((!empty($row2['img_local'])) && (file_exists($row2['img_local']))) {
echo '<img class="image--cover" id="blah" src="'.$row2['img_local'].'" alt="Avatar" title="DEFINIDA" onerror="this.onerror=null;this.src=1.png;">';
} else {
echo 'Show a default image.'; // <img src="path_to_default_image" alt="Default_image"/>
}
} ?>" alt="Avatar" title="DEFINIDA" >
答案 0 :(得分:0)
我设法工作了,最终代码:
<?php
$query2=mysqli_query($conexao,"select * FROM esc_usuarios_fotos WHERE img_usu_codigo = '" . $_SESSION['codigo'] . "'");
while($row2=mysqli_fetch_array($query2)){
if ((!empty($row2['img_local'])) && (file_exists($row2['img_local']))) {
echo '<img class="image--profile" src="'.$row2['img_local'].'" title="Clique para abrir seu perfil">';
} else {
echo '<img class="image--profile" src="images/user.png">';
}
}
?>