How to insert a mysql database image into a datatables

Asked

Viewed 67 times

0

I am starting in PHP programming and downloaded a source code to be learning, and this code presents a datatables, in which I want to insert an image in the grid that is in the mysql database. My code below for anyone who can guide me, I am grateful to all

$dados = array();

while( $row =mysqli_fetch_array($resultados) ) 
{

     $dado = array();

     $Foto = $row["Imagem"];

     $dado[] = "<img src='Fotos/' 
                    $Foto class='img-responsive img-circle'  width=20 height=20/>";

    $dado[] = $row["Id"];
    $dado[] = utf8_encode($row["Descricao"]);

                    $dados[] = $dado;
};

Not showing the image on the datatables grid.

  • An Obs.: you are putting the variable $Foto (assuming it is the name of the image) outside the src.

  • What is the image format? CLOB?

  • I am using in the table the field Image varchar(15), and the images have extensions . jpg

  • I am saving in the table photo variable only the name of the image. ex: prod1.jpg

1 answer

0

To add the database image just save the name, for example "image.jpg", to receive the image and like all other fields, the only difference is in the call you have to enter the path where the photo is stored.

<img src="caminho/nome_guardado_na_bd" class='img-responsive img-circle'  width=20 height=20/>";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.