include an entire directory of html files

Hi,

First post so I will introduce myself - know a little code but not enough to say I can code in php

Polite and humorous, I welcome any help :slight_smile:

Any way my first question is:
I would like a folder in a directory to have it’s web pages added to the main html file using include

so instead of just adding one page.html file I could include whatever is in the folder.

folder

page1.html
page2.html
page3.html
page4.html
page5.html

so that later on I can add say page6.html and it will get automatically added after it is dropped into the same folder.

The reason is I add shows to the directory and they are these little thumbnail html pages which link to the show. They aren’t an entire page so not a page within a page - they are designed to work with php.

right now that works if I do it individually for each one but I would rather just have include for the folder to save time and for other reasons.

nevermind used

<?php foreach (glob("pages_subjects/Sub_Sci/*.php") as $filename) { include $filename; } ?>

I’m still waiting for you to introduce yourself… :stuck_out_tongue: ;D

I can’t help wondering why you have a directory full of files. It’s not the most efficient data store, and pretty much any other solution would be better. Considered using a database, or at least a json-file?

Sponsor our Newsletter | Privacy Policy | Terms of Service