What your asking to do is very confusing, but I understand, because I am cool like that.
The best way to do this to set a flag in the data, have a field in the database that is called locked or such that is a simple boolen value 1=true, 0=false
Then on the 7th of the month at midnight run a cron job that updates all the records before the current month with a 0 and set them to a 1.
It would be pretty trivial to write a cron job to do that maybe 20 lines of code tops.
Brief example (psudo code)
$date = (new DateTime())->modify('first day of this month')->format('Y-m-d');
$Sql = "UPDATE tbl SET locked = 1 WHERE DATE(date_field) < '{$date}' AND locked=0";
$DB->query($Sql);
Cron: if you don't know what it is
https://en.wikipedia.org/wiki/Cron
Use cron to schedule jobs (commands or shell scripts, including PHP )
to run periodically at fixed times, dates, or intervals.
If they can only edit tell the 7th of the next month, then on the 7th of each month all the data from last month is no longer editable.
Then when you pull them to edit, you just do
SELECT * FROM table WHERE locked = 0
That is if you truly what it to stop on the 7th and not a month. AS I said in the comments if I put a record on the 1st that gives me that whole month + 7 days, if I did it on the last day, I would have only 7 days to edit the record.
It's not as trivial to write a date range query for this as it first seems. Because if it's before the 7th, you have to select everything from last month and everything from this month ( tell the current date ). But if it's the 8th, you have to select everything from the beginning of the month tell the current data ( omitting last month ). So the query would change depending on the day it currently is.
To try to filter the data after pulling it out seems like a waste, because you will always pull more records then the user can edit, and then you have to work out the date switch anyway.
An advantage of having a locked
field also, it that you can selectively unlock a record for a user so they could edit it again, just by fliping the 1 back to a 0. ( -note- the cron job I outlined above would re-lock it ) The point is it would be possible to allow them to edit specific records without code changes.
IMO, it's the best way to do it.