1
1
17aPaBo3uK2017-06-05 12:27:06
PHP
17aPaBo3uK, 2017-06-05 12:27:06

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

3 answer(s)
A
Andrey Burov, 2017-06-05
@17aPaBo3uK

Save in session or in cookies the ID of the displayed banner.

M
Maxim Timofeev, 2017-06-05
@webinar

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.

P
Pavel, 2017-06-05
@PavelFokeev

And change your nickname, 2007 is long gone :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question