Creating an image gallery using html image tag in a php for loop -


i want create online image gallery. have folder containing n number of thumbnails , name tn_1.jpg, tn_2.jpg , on.this code planning implement.

<?php  ($i=1;$i<=n;$i++) { echo '<img src="images/tn_'.$i.'.jpg"/><br>'; } ?> 

do think way of creating online gallery or should follow method?

unless running framework on top of vanilla php (either php or javascript), way display images in folder on web page.

you need add logic names of files within directory , run loop.

$files = scandir('/path/to/image/directory'); foreach($files $file){     echo '<img src="/path/to/image/directory/' . $file . '"/><br>'; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -