一万条数据怎么一条一条由用户点击输出

WBOY
Release: 2016-06-13 12:56:06
Original
1091 people have browsed it

一万条数据如何一条一条由用户点击输出?
在做一个日志浏览功能,假设数据库中有一万条短数据,都符合varchar(20)类型,但是用户可以自由选取其中的一条或多条数据生成自己的数据表,然后通过PHP和AJAX在前端调用出来,显示方法是点击按钮一次调用一条。
-----
把问题再具体描述一下:
一个表中有一万条数据,现在需要在前台逐条输出,每次只输出一条,不是一次输出完而是用户通过点击按钮来输出下一条。
这个功能怎么做出?难点在于如何用AJAX配合PHP来操作一个类似游标的指针一直往下指或跳到某个数据去(因为用户不一定一直输出下一条,也可以输出上一条或指定某条)。每次都取出所有数据显然浪费很多资源。
还有,不使用MYSQL游标。因为最终的实现未必是直接从MYSQL读数据,而是从xml甚至txt里读取一定格式的数据再拆分。


------解决方案--------------------
数据总个排序字段吧

按排序字段 一次查找

比如 id

id=20的下一条 查找 id > 20 的一条
------解决方案--------------------
<br />
SELECT fields FROM tableName LIMIT $page,1<br />
Copy after login

这样不行吗?
------解决方案--------------------
不管是哪个用户查看20号数据 它的下一条数据都是id > 20 不用维护什么队列

传递id = 20 就可以了
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!