-1

I have this problem when I read a picture from the database.

It shows like this:

enter image description here

This my code:

<?php
include 'Header.php';
include 'yzd.php';
?>

<div class="container">
<h1> All Project </h1>
<?php
$posts = mysqli_query($db_connect,"select * from Project order by id desc");

while($post = mysqli_fetch_array($posts)){
    echo "
    <article>
    <a href='Project.php?id=$post[id]'>
    <h1>$post[NameProject]</h1>
    </a>
    <p class='text-muted']>
    <h3>$post[TypeProject]</h3>
    </p>
    <h4>$post[Description]</h4>

    $post[Pic];

    <p>-----------------------------------------------------------------------------</p>
    </article>";

}
?>

[![enter image description here][2]][2]

Younes Zaidi
  • 1,180
  • 1
  • 8
  • 25

1 Answers1

2

Try converting the raw image output into a base 64 data URI (see here) you may be able to do this by changing

$post[Pic]

into

<img src='".'data:image/png;base64,' . base64_encode($post["Pic"])."'/>

Given all of the images in your databases are stroed as png(s) The type may need to be varied dependent on image type.

Please in the future use code snippets and not screenshots.

Community
  • 1
  • 1
ryanolee
  • 89
  • 4