Como mostrar una imagen que esta guardada en una base de datos como link?

  • Autor Autor David Batista
  • Fecha de inicio Fecha de inicio
David Batista

David Batista

Dseda
Verificado
Verificación en dos pasos activada
Verificado por Whatsapp
Verificado por Binance
Hola

mi base esta en phpmyadmin no guarda la imagen en si sino el link a esta como texto
debo mostrar un listado de clientes(nombre,identidicacion etc etc y la foto) todo cool execto por la imagen no tengo idea de como hacer
para que muestre la imagen en miniatura y no como se muestra en la imagen que pongo mas adelante

Con este formulacio registro a la persona
Imgur: The most awesome images on the Internet
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
	<title>Registro de cliente</title>

<center><br><br><br><br>
Cedula:
<input type="text" name="ced" size="20">
<br><br>
Nombre:
<input type="text" name="nomb" size="20">
<br><br>
Apellido:
<input type="text" name="ape" size="20">
<br><br>
Telefono:
<input type="text" name="tel" size="20">
<br><br>
Direccion:
<input type="text" name="direc" size="20">
<br><br>
Correo:
<input type="text" name="mail" size="20">
<br><br>
Foto:
<input type="text" name="imagen" size="20">
<br><br>
<input type="submit" value="Registrar">
</center> 
</body>
</html>

esto mete lo que se pone en el formulario anterior a la base
PHP:
<?php

$mysql=new mysqli ("localhost", "root","","peliculas"); 
if ($mysql->connect_error)
	die('Problemas con la conexion a la base de datos');

$mysql->query("insert into clientes(cedula,nombre,apellido,telefono,direccion,correo,foto) values ('$_REQUEST[ced]', '$_REQUEST[nomb]','$_REQUEST[ape]', '$_REQUEST[tel]', '$_REQUEST[direc]', '$_REQUEST[mail]','$_REQUEST[imagen]')") or 
	die($myslq->error);

$mysql->close();

echo 'Se almacenaron los datos';

?>

y aqui se muestra el listado
Imgur: The most awesome images on the Internet
PHP:
<html>
<head>
<meta charset="UTF-8"/>
  <title>Listado clientes</title>

  <style>
  .tablalistado {
    border-collapse: collapse;
	box-shadow: 0px 0px 8px #000;
	margin:20px;
  }
  .tablalistado th{  
    border: 1px solid #000;
    padding: 5px;
    background-color:#51666B;	  
  }
  
  .tablalistado td{  
    border: 1px solid #000;
    padding: 5px;
    background-color:#51666B;	  
  }
  </style>

  <?php
    $mysql=new mysqli("localhost","root","","peliculas");
	if ($mysql->connect_error)
	  die("Problemas con la conexión a la base de datos");

    $registros=$mysql->query("select cedula,nombre,apellido,telefono,direccion,correo,foto from clientes") or
	  die($mysql->error);
  
    echo '<table class="tablalistado">';
    echo '<tr><th>Cedula</th><th>Nombre</th><th>Apellido</th><th>Telefono</th><th>Direccion</th><th>Correo</th><th>Foto</th></tr>';
    while ($reg=$registros->fetch_array())
    {
      echo '<tr>';
      echo '<td>';
      echo $reg['cedula'];
      echo '</td>';	  
      echo '<td>';
      echo $reg['nombre'];	  
      echo '</td>';	
      echo '<td>';  
      echo $reg['apellido'];   
      echo '</td>';
      echo '<td>'; 
      echo $reg['telefono'];   
      echo '</td>'; 
      echo '<td>'; 
      echo $reg['direccion'];   
      echo '</td>';
      echo '<td>'; 
      echo $reg['correo'];   
      echo '</td>';
      echo '<td>'; 
      echo $reg['foto'];   
      echo '</td>';
      echo '</tr>';	  
    }	
    echo '<table>';	
	
   $mysql->close();

  ?>  
<br>

</body>
</html>
 
en
PHP:
echo $reg['foto'];
cambia por
PHP:
echo "<img src=\"".$reg['foto']."\">";
 
Atrás
Arriba