I'm building an on-line multi-player board game and I have a function that creates a new board. I need to do that after every round, but i can't seem to be able to make it execute only once for all users. I call the function when the timer reaches 0, on the page where the game is situated, so it executes for every user that is on that page.
Thus, the function generates a new board as many times as there are users playing the game at that moment, but i want it to generate only one board.
So, my question is how can i make a PHP function execute only once and not as many times as there are pages open?
Edit on the system: Users play for 90 seconds then they wait 15 second while they see the round results and then the whole thing repeats again and again. And if you enter the page in the middle of the round you have the option to wait until a new round begins or enter the round right then. So i have no idea where to call the function. I tried calling it when the pause menu begins where the results are displayed, but it just executes the function for all users.It still works cause i still get one board at the end of all executions, but it's not right, especially if there will be more than hundreds of people playing, the board will be generated hundreds of time. And also, what generates the board is a c++ .exe that creates an XML on the server.I execute that exe from PHP and do some additional things also.
I have no idea where to call that function. How do i prerender the board as you said? The function still has to be on a page that some user has to access for it to execute. It's mind boggling.
And also i tried adding info in the database to see if the function has been called before, but it still happens for all users at the same time.