Answer the question
In order to leave comments, you need to log in
PHP: display banner one by one on page refresh?
Hello, I am making a banner rotator and I need to display banners in turn every time the pages are updated, how can I do this correctly?
I don’t know how to determine that a specific banner has already been displayed and the next one should be shown in ID / queue
Banners are stored in the database - the banners table
Answer the question
In order to leave comments, you need to log in
Add a counter to the table, update it with each banner request. Accordingly, choose the one whose counter is less. If you also need to show evenly for each user, then you can, as Andrey Burov suggested, write in the session. I would write to localStorage, and load banners asynchronously, choosing the one with the smallest counter and minus those in localstorage. Then part of the sample will fall on the client, which will save resources a little.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question