problems when displaying an image in a php table with SQL

0

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

This is my code

<?php
    $servername = "***";
    $username = "***";
    $password = "***";
    $dbname = "registrodatos";

$conn = new mysqli($servername, $username, $password, $dbname);
      if($conn->connect_error){
        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'>
                <thead>
                    <tr id='titulo'>
                        <td>Nombres</td>
                        <td>Apellido</td>
                        <td>Tipo de Documento</td>
                        <td>Numero de Documento</td>
                        <td>Numero de Registro</td>
                        <td>Horas</td>
                        <td>Nombre de contacto</td>
                        <td>Telefono</td>
                        <td>Foto de usuario</td>
                        </tr>

                </thead>


        <tbody>";

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


        {
            $salida.="<tr>
                        <td>".$fila['nombres']."</td>
                        <td>".$fila['apellidos']."</td>
                        <td>".$fila['estado_civil']."</td>
                        <td>".$fila['documento']."</td>
                        <td>".$fila['registro']."</td>
                        <td>".$fila['ubigeo']."</td>
                        <td>".$fila['nombredecontac']."</td>
                        <td>".$fila['telefono']."</td>

///------- Lo que deseo es que acá me muestre la imagen y no la ruta de la imagen que esta almacenada en el SQL.-------------
                         <td>".$fila['fotos']."</td>
///----------------la imagen esta guardada en el SQL type   longblob.-----





                    </tr>";

    }
        $salida.="</tbody></table>";
    }else{
        $salida.="NO HAY DATOS :(";
    }


    echo $salida;

    $conn->close();



?>
    
asked by yamicu 29.12.2018 в 19:41
source

1 answer

0

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