Selecting random data from database with selectionhistory

This is my first question here, I’m sorry if my question isn’t written good enough ^^
I’m currently supposed to write a small web-app that is supposed to show so called “mantras”.

The requirements are:
1. It should always show diffrent data from database – that means that
if “Mantra1” was shown the next Mantra cant be “Mantra1” again.
2. Every “Mantra” should pop-up at some point
3. It should save the history outside of the session.
4. Multiple “Mantras” can be used by diffrent units -> that means if “Unit1” and “Unit2” both can see “Mantra1”, it should also save which unit already got the “Mantras”, so if “Unit1” got “Mantra1”, “Unit2” should still be able to get the “Mantra1” as an output.

So basically, read data from a database -> save the record that was randomly chosen from the data in a selection history of some sort -> if button is pressed get new data, but not the ones that have been shown already.
The random selection will happen inside my php code.
basic program flowchart

What I’ve tried / what my approach was:
I currently have three tables in my Database (Mantras (Fields: ID, Units (which units can see the mantra), mantra_text), Units (Fields ID, unitname) and selectionhistory (ID, mantra_id, unit_id)).
My idea was, to save the mantra/unit_id into the selectionhistory with a date, when it was selected, then delete the entrys after x days. And maybe set the x days to the amount of mantras that are available for the units.

I’ve done some research the past few days, but I didn’t find any posts with the same issue.

My question is, are there any best practices for this kind of problem, are there posts somewhere with a similar problem or does anyone have an idea how to they would solve this kind of problem?

If you need anymore information to help me, please let me know!
Thank you for your time 🙂