Ever Castellon Posted November 18, 2019 Share Posted November 18, 2019 Hola a todos, tengo una solución en .Net la cual tiene una pagina que muestra las imagenes sacadas de la tabla llamada "peliculas",quisiera que en ella se muestren todas las imagenes de la tabla llamada "peliculas" ya que son muchisimas y no quiero estar todo el tiempo referenciando con un <input type="image" src="imagenes/imagen1.jpg" onclick=".../"> a cada una de ellas y quisiera hacerlo todo de una sola, He leído foros con códigos que hacen en PHP pero no se como adaptarlo, el codigo en php que quiero implementar es este: <?php require("conexion.php"); //conectando a la base de datos $select='select * from peliculas'; $resultado=mysqli_query($miconexion,$select); while($filas=mysqli_fetch_array($resultado)) { echo '<div>'; echo '<input type="image" src="data:image/jpg;base64,'.base64_encode($filas["Imagen"]).'" onclick="">'; } echo '<div>'; mysqli_free_result($resultado); ?> Gracias. Link to comment Share on other sites More sharing options...
Funce Posted November 24, 2019 Share Posted November 24, 2019 Instead of storing your image data in the database, I'd recommend storing it in the file system, and storing the path. Do you have a database that is doing this? Then you could try this <?php require("conexion.php"); //conectando a la base de datos $select = 'select * from peliculas'; $resultado = mysqli_query($miconexion, $select); while ($filas = mysqli_fetch_array($resultado)) { ?> <div> <input type="image" src="<?= $filas["ruta_imagen"]; ?>" onclick=""> </div> <?php } mysqli_free_result($resultado); ?> Alternatively if all your file names are like the following: imagenes/imagen1.jpg imagenes/imagen2.jpg imagenes/imagen3.jpg etc Then you can also try something like this (without a database. <?php for (var i = 1; i <= 3; i++) { ?> <input type="image" src="imagenes/imagen<?=i;?>.jpg" onclick=""> <?php } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now