Php + MySQL 横幅旋转器按顺序排列

发布于 2024-08-30 02:11:32 字数 108 浏览 1 评论 0原文

我在 MySQL 中有带有广告的表。我想按顺序轮换横幅(不是随机)。我需要什么函数或机制来从 MySQL 表中选择广告以按顺序显示它,例如 1,然后 2,然后 3 ... 然后再次 1,2,3... ?

I have table with advertisement in MySQL. I would like to rotate banners by order (NOT RANDOM). What function or mechanism I need to SELECT advertisement from MySQL table to show it in order, like 1, then 2, then 3 ... then again 1,2,3... ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄居人 2024-09-06 02:11:32

在不同页面加载时向同一用户显示横幅 1、横幅 2、横幅 3?

你可以使用cookie:

//the banner that the user last saw
$banner = (isset($_COOKIE['banner']) && $_COOKIE['banner'] < 3)? $_COOKIE['banner']++ : 1;

//mysql to select and show the banner

$_COOKIE['banner'] = $banner;

Show banner 1, then banner 2, then banner 3 to the same user on different page loads?

You could use a cookie:

//the banner that the user last saw
$banner = (isset($_COOKIE['banner']) && $_COOKIE['banner'] < 3)? $_COOKIE['banner']++ : 1;

//mysql to select and show the banner

$_COOKIE['banner'] = $banner;
分分钟 2024-09-06 02:11:32

如果您希望每次点击都能获得下一个横幅(按顺序),那么您需要在服务器上创建一个位置来存储当前横幅编号。 MySQL 中的表将是显而易见的选择。然后在每次点击时增加表中的计数器,并在到达最后一个横幅时将其重置为开始。

If you want each hit to get the next banner (in order), then you need to create a place on your server to store what the current banner number is. A table in MySQL would be the obvious choice. Then get increment the counter in the table every hit and reset it to the start when you get to the last banner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文