problems when displaying an image in a php table with SQL


Good I have a problem with wanting to show images in a table.

This is my code

    $servername = "***";
    $username = "***";
    $password = "***";
    $dbname = "registrodatos";

$conn = new mysqli($servername, $username, $password, $dbname);
        die("Conexión fallida: ".$conn->connect_error);

    $salida = "";

        $query = "SELECT * FROM registrodatos WHERE Name NOT LIKE '' ORDER By Id_no LIMIT 25";

    if (isset($_POST['consulta'])) {
        $q = $conn->real_escape_string($_POST['consulta']);
        $query = "SELECT * FROM registrodatos WHERE nombres LIKE '%$q%' OR apellidos LIKE '%$q%' OR documento LIKE '%$q%' OR nombredecontac LIKE '%$q%' OR telefono LIKE '$q' ";


   $resultado = $conn->query($query);

    if ($resultado->num_rows>0) {
        $salida.="<table border=1 class='tabla_datos'>
                    <tr id='titulo'>
                        <td>Tipo de Documento</td>
                        <td>Numero de Documento</td>
                        <td>Numero de Registro</td>
                        <td>Nombre de contacto</td>
                        <td>Foto de usuario</td>



        while ($fila = $resultado->fetch_assoc())


///------- Lo que deseo es que acá me muestre la imagen y no la ruta de la imagen que esta almacenada en el SQL.-------------
///----------------la imagen esta guardada en el SQL type   longblob.-----


        $salida.="NO HAY DATOS :(";

    echo $salida;


asked by yamicu 29.12.2018 в 19:41

1 answer


Inside the td you should use the img tag. This is the one that displays your image:

<td><img src=".$fila['fotos']." ></td>

What is stored in that variable is the route, that route should go in the src attribute of the img tag. Then it depends on you the size and style you want to give it inside your table.

answered by 29.12.2018 в 20:23