image from database phpmyadmin

Viewed 42

I have a little problem I try to display a url image that there is in my phpmyadmin database, but nothing is displayed. I am trying to display an image from my database. I put you my code and my line of the database. Thank you in advance for your help !enter image description here

see if I made a mistake in the code, or if I used the wrong path

the URL of my image is called "img_l" in my database and it is in a category called "liste"

Voici mon code :

<?php
    $bdd = new PDO('mysql:host=localhost;dbname=animebd;chaset=utf8','root','');
    $req = $bdd->query('SELECT img_l,nomL FROM liste');
    while($donnees = $req->fetch()){
        echo('<img style="width:50px;height:50px;border-radius;:500px;" img_l = "' . $donnees['img_l'] . '"/><br/>');
    }
?>
1 Answers

In image tag, you don't have src attribute. You must add it and concatenate your data from db with images directory.

$path = './public/images/' . $donnees['img_l'];

of course my answer is valid only if $donnees['img_l'] is the filename with extension (mycar.jpg)

Related