Ever Castellon 0 Posted November 18, 2019 Report 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. Quote Link to post Share on other sites
Funce 42 Posted November 24, 2019 Report 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 } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.