请问随机显示有关问题

WBOY
Release: 2016-06-13 12:14:54
Original
848 people have browsed it

请教随机显示问题
请教一下,
如果使用PHP+Mysql,
想从数据库搜索出符合要求的数据,顺序随机显示,并分页显示。如果要想让数据不重复,特别是不同的页,不能有相同的数据,
请问如何实现?
(目前遇到的问题是:不同的分页,有的数据是相同的)
谢谢!

------解决思路----------------------
你之前有重复,估计你是用order by rand(); 后分页导致的。

要做到随机不重复,可以这样做,用一个临时文件,记录已经使用过的id,在下一次select时排除。
------解决思路----------------------
先将随机的结果集全部存入临时表

然后再对临时表分页
------解决思路----------------------
相同的种子将产生相同的随机数序列
由 ...... order by rand()
变为 ......order by rand(n)
并用你认为合适的方式保存种子 n

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!