Pulling one entry from a database based on current date

So I have created a database for my church website that the admin can upload our current sermons easily and it update the website automatically based on what the date is.

Use Case:
Admin Uploads Sermon 3 months before it starts → No Change on the website → 3 Months pass and it’s the first Sunday that sermon is airing —> Website updates to show the sermon.

openarms.site down at the bottom is where I want it to be viewable, showing the previous 10ish sermons with the most current one being at the left.

I’ve successfully made the code to upload the sermons to the database but I am not sure where to start on the website updating it’s self. Does anyone have any ideas?

So each sermon will have an associated date (in the future when uploaded) when it is intended to be viewed, right?
Then your upload form will need a date field, and that date will be stored in the table with the associated sermon.

So you will then want to make a selection of sermons with a date equal to or less than the current date, ordered by date descending, limited to 10 (they don’t do “ish” very well, so we will say 10 exactly).

What type of database and programming language are you using?

1 Like

I’m using PHP and mySQLi
I’ve got the input all done and the database made. It’s the showing of it to a certain criteria I’m struggling with a starting point for.

Something like:-

SELECT `whatever` FROM `sermons`  /* select columns from table */
WHERE date <= NOW()            /* Dates today and before */
ORDER BY date DESC          /* Starting most recent, then those previous */
LIMIT 10           /* Just the most recent ten */

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.