Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:55:46+00:00 2026-06-12T00:55:46+00:00

I have a site which will have a gallery with 3 sections. Each section

  • 0

I have a site which will have a gallery with 3 sections. Each section has up to 30 images. I will store the images in folders relating to the relevant sections (ie “img/gallery/category1”, “img/gallery/category2” and “img/gallery/category3”)

Basically instead of writing html to display each individual image, I would like to have a javascript loop which will look in the folder and display each image, and place the url within a predefined snippet of code, ie:

<div class="span4">
  <img src="img/gallery/category1/IMAGE-FILENAME1">
</div>

<div class="span4">
  <img src="img/gallery/category1/IMAGE-FILENAME2">
</div>

… etc, until all images from the folder have been processed… (also, I know I could be a bit smarter with the html above, but I want to communicate that I want each found image url to sit amongst a repeated snippet of code).

I’m still training in javascript, so I wondered whether there was a way I could do this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:55:47+00:00Added an answer on June 12, 2026 at 12:55 am

    I found an alternative solution.

    I wasn’t quite ready to tackle AJAX, JSON or anything listed below just yet. So I decided to look into using PHP. Solution as folows:

    I first of all used the following to go to and read the contents of the folder to an array:

    $directory = "DIRECTORY"
    
    $dirhandler = opendir($directory);
    
    $nofiles=0;
    while ($file = readdir($dirhandler)) {
    
    if ($file != '.' && $file != '..')
    {
      $nofiles++;
      $files[$nofiles]=$file;                
    }}
    

    And then using a foreach loop I iterated through the array, everytime echoing the html output which referenced the filename found.

    Works perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a WP site which will have multiple subjects. Each subject
Possible Duplicate: Saving images: files or blobs? im building a site which will have
I'm currently working on an oophp application. I have a site class which will
I have a site which has a lot of corners. I don't want to
I have one core site which has all the core functions. I then need
I am creating a site which will have a desktop and a mobile theme.
I have a web site which has 2 domains ex : www.site1.com www.site2.com (which
I have an asp.net web site which will send several ExecuteNonQuery() statements (stored proc)
I'm building the back end to a site which will have multiple widgets on
Hi I am devloping the a asp.net site which will have lots of user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.