我正在尝试一种方法,每次有新的 cookie 集或每次用户登录和注销时,我都可以从文件夹中的大约 100 张图像中显示 5 张图像。我已经尝试过使用 javascript 根据星期几显示不同的图像,但是我真正想要的是一次显示 5 张图像的方法,附带的链接每次用户登录和注销时都会改变?有人可以指出我的写作方向吗,我是 php 新手,所以即使是最小的代码示例也会有所帮助,谢谢。
这是我的 javascript 代码,它显示基于当天的图像,我不知道这是否有帮助?
<script type="text/javascript" language="JavaScript">
var now = new Date ();
var day = now.getDay();
//the week begins on SUNDAY
if(day == 0) document.write("<p><a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad0.png' alt='sunday' width='180' height='180' border='0'></a></p><p><a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad0.png' alt='sunday' width='180' height='180' border='0'></a></p>");
if(day == 1) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad1.png' alt='monday' width='180' height='180' border='0'></a>");
if(day == 2) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad2.png' alt='tuesday' width='180' height='180' border='0'></a>");
if(day == 3) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad3.png' alt='wednesday' width='180' height='180' border='0'></a>");
if(day == 4) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad4.png' alt='thursday' width='180' height='180' border='0'></a>");
if(day == 5) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad5.png' alt='friday' width='180' height='180' border='0'></a>");
if(day == 6) document.write("<a href='YOUR-LINK-HERE'><img src='../PTB1/data/adverts/ad6.png' alt='saturday' width='180' height='180' border='0'></a>");
</script>