使用PHP随机显示横幅? [英] Random display of banners using php?

查看:74
本文介绍了使用PHP随机显示横幅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这里我有相同的图像存储在数据库中,具有不同的ID'并且还存在一些其他图像。


这里我必须随机显示横幅我已经拍摄了imageid并随机显示。由于存储了相同的图像,我需要等待很长时间(刷新页面)才能更改图像。


这里的问题是如果我在db中存储了相同的图像很多我必须在每次刷新页面时显示独特的图像。(如果我刷新页面而不应显示以前显示的图像,则应显示新图像。)


请帮我一些一个解决这个问题


提前致谢


Ram

解决方案

I真的不明白你对数据库谈话中存储的所有图像的意思。


但是让我们说你有一系列的图像,你希望其中一个出现在当用户请求页面时出现横幅,并且出现哪一个是随机的。


然后,您只需将图像命名为名称中有一个整数计数器例如,让我们说你有5张图片,所以把它们命名为bimg1.jpg ,bimg2.jpg,bimg3.jpg,bimg4.jpg,bimg5.jpg。


然后,当用户发出页面请求并调用您的PHP脚本时,您会生成一个随机整数,此示例中的值限制在值1和5之间,然后您构建使用此值的图像名称,例如

展开 | 选择 | Wrap | 行号


我当然希望coolsti能做对,因为我不知道你的问题或疑问是什么!如果你想获得更多的支持,请用简单明了的英语解释你的问题或疑问。


Ronald


听起来像你的尝试显示随机图像,但你不希望同一图像连续出现两次?


如果是这样你只需存储你显示的最后一张图像的图像在

Hi to All,

Here i have the same image stored in the db with different id''s and also exist some other images.

Here i have to display banner randomly i have taken imageid''s and displayed randomly. Because of same image stored many time i have to wait long time(refresh the page) for change of image.

Here the issue is though if i have same image stored in the db many times i have to display unique image on every refresh of the page.( means previously displayed image should not display if i refresh the page instead fresh image should appear.)

please help me some one in solving this

Thanks in Advance

Ram

解决方案

I really do not understand what you mean with all the images stored in the database talk.

But let us say you have a series of images, and you wish one of them to appear in the banner when a user requests a page, and which one does appear is to be random.

Then all you have to do is name the images such that there is an integral counter in the name, for example let us say you have 5 images, so name them something like bimg1.jpg, bimg2.jpg, bimg3.jpg, bimg4.jpg, bimg5.jpg.

Then when the user makes a page request and calls your PHP script, you generate a random integer, here in this example limited between the values 1 and 5, and then you build up the name of the image using this value, e.g.

Expand|Select|Wrap|Line Numbers


I sure hope coolsti got it right, because I have no clue what your problem or question is! If you want more support on this, please explain your problem or question in plain and clear english.

Ronald


Sounds to me like your trying to display a random image, but you don''t want the same image to appear twice in a row?

If so you can simply store the image of the last image you display in the


这篇关于使用PHP随机显示横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆