You'll want to have a structure like this:
id int (primary key) url varchar(512) image varchar(128) active tinyintAs for rotation, so long as your banner ad table doesn't get larger than a thousand rows, there isn't much of a concern, however, I would highly recommend reading this blog post: http://jan.kneschke..../order-by-rand/
With that said, the simplest solution for you, that will certainly work fine for quite a while:
SELECT * FROM banner WHERE active = 1 ORDER BY RAND() LIMIT 1If you expect rotation over time without reloads, then cyberRobot's point should be taken into account. Often people will utilize an iframe and place the banner in the iframe, which can then have a simple meta refresh tag in the header of the code.
- holly9 likes this