- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I know, the title does look a bit weird – I know how to style images but not in this case. In my graphics.php page I have images that are uploaded automatically being ‘written’ or ‘placed’ on the page with a php script as you can see here:
<div class="photos">
<?php
$dirname = "includes/img/uploads/";
$images = glob($dirname."*.png");
foreach($images as $image) {
echo '<img src="'.$image.'" class="img-responsive" alt="Responsive image" /><br />';}
?>
</div>
I am trying to find a way to make all images that are uploaded placed in a 3 column grid to showcase my graphics that I have done but can’t seem to find a way to correctly style them while in the php tags.
Thanks! I didn’t know I can put html tags inside of my php tags like that – I will try and use this codepen as a reference to style my images.
I didn’t know I can put html tags inside of my php tags like that
Yeah… and if you want your text editor to use its pretty colours:
<?php foreach($images as $image) { ?>
<li>
<img />">
</li>
<?php } ?>
I prefer to use the alternate syntax and comment the closing tags for things like this:
<code class="php"><?php foreach($images as $image): ?>
Maybe sometime in the future you will open the code for this page, and find a lone <?php } ?>
and facepalm yourself: “What the heck did I do here and where this bracket belongs to?”