I am a beginner in PHP and would like to load a daily meditation every day that is specific to that day.
So on January 1st, I would call the quote from 1_1.php and on the 2nd 1_2.php, and so on until February 1st which would call 2_1.php and on the 2nd 2_2.php on the third 2_3.php.
Is this possible and how hard would it be?
It would also be acceptable to have 365 files where it just called the next one in order every twenty-four hours, or one file with 365 lines and called a different line every day, but I do not know how to do this as I only know how to build in html and design so any help or advice would be great.
I would most definitely not use 365 different files. It might be sensible to use a database, but since these seem to be one-liners and you are new to PHP, the simples method is to them in a big array. The downside of this is that the whole array will be read and parsed on each page load. But I wouldn’t worry about the performance of that until it becomes a problem.
Then access them as:
If you prefer, insted of using the format
dd-Monfor array keys, you can use numeric months as in:The complete bit to include inside your PHP page (note it will need to be a .php page, rather than .html) is:
You can alternatively store the huge array in its own file called meditations.php, and include it:
File meditations.php
Main file:
To include this in a plain HTML page (not .php), you’ll need an
<iframe>. Assuming your PHP is working correctly in a file calledmeditations.php, call the<iframe>like this: