Jump to content

Highslide gallery with php

Go to solution Solved by Jckf,

You seem to be confused. What you're doing here is dumping 273 strings inside the href and src attributes of your elements, instead of what I assume you want to do, which is loop over some image files in a directory, and echo out anchor and image elements for them. The following code demonstrates a simple loop:

 

<?php foreach (glob($img_dir . "/*") as $filepath) { $filename = basename($filepath); ?>    <a href="path/to/image/<?= $filename ?>">        <img src="path/to/thumb/<?= $filename ?>">    </a><?php } ?>

So, I was developing a gallery using highslide and decided to use php to reduce the typing of html.
 

The following is code of my html with php

<div class="highslide-gallery">    <a href= "<?php $img_dir for($i=1;$i<=273;$i++) { print_r( "1 ($i).jpg");}?>" class="highslide" onclick="return hs.expand(this)">	<img src="<?php $thumb_dir for($i=1;$i<=273;$i++) {print_r( "1 ($i).jpg");}?>" alt="Highslide JS"		title="Click to enlarge" />                </div>

the print_r statement here prints all the output results.

I need a method where I can print each output at a stance or similar.

 

Thank you for help.

Evil's Advocate Approved.

Link to comment
https://linustechtips.com/topic/456965-highslide-gallery-with-php/
Share on other sites

Link to post
Share on other sites

You seem to be confused. What you're doing here is dumping 273 strings inside the href and src attributes of your elements, instead of what I assume you want to do, which is loop over some image files in a directory, and echo out anchor and image elements for them. The following code demonstrates a simple loop:

 

<?php foreach (glob($img_dir . "/*") as $filepath) { $filename = basename($filepath); ?>    <a href="path/to/image/<?= $filename ?>">        <img src="path/to/thumb/<?= $filename ?>">    </a><?php } ?>
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×