求一段源码
我要写一个分页
与 新浪微薄的分页有点相同 (向下拉到底就加载,加载三段后,就显示分页页数)。
还请教一下怎么写,我下了一个新浪微薄源码,可惜是JAVA的,看不懂。
有高手做过嘛?
------解决方案--------------------
按需加载?
这个效果需要由 js 实现,php只负责提供数据
------解决方案--------------------
jquery 有这种插件 显示内容,比较多的是显示图片,屏幕到了哪一块就加载,不过插件名字 还是老样子 不记得了.
------解决方案--------------------
有好多:
10款无限滚动自动翻页jquery插件
------解决方案--------------------
关键在于判断垂直滚动条的位置
当滚动条顶部到达某个位置时,通过 ajax 向 php 请求数据
如此循环而已
------解决方案--------------------
一面就10条微博, js维护当前用户页面上的条目个数, 用ajax拉更新, 更改条目个数, 条目个数超30就JS删除后20条, 添加下一页按钮.
其他状态是服务端维护的:
1,用户ajax拉数据,由服务端数据库维护上一次拉时间t1,将t1之后的条目推给用户。
2,用户点击下一页,服务端查数据库按时间排序,分页即可。
有难度吗。
------解决方案--------------------
我已经说了,这不是 php 的事情
给你个核心代码,接下来的事情你还是要自己学着做
- JScript code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(window).scroll(function() { var h = $(this).scrollTop();// + $(this).height(); var t = $('#control').offset().top; if( h >= t) { $("#view").html($("#view").html() + h + ':' + t + ' new data '); } }); }); </script> <div id="view"></div> <div id="control" style="height:300pt">控制位</div> <br><font color="#e78608">------解决方案--------------------</font><br>简单啊,滚动条滚动到指定位置就用AJAX拉取新的记录,每次拉取缓存一下最后一条记录的ID。<br><br>在DIV里显示内容,判断滚动条位置到达DIV底部的时候,执行拉取方法就好了。 <br><font color="#e78608">------解决方案--------------------</font><br>document.documentElement.scrollTop || document.body.scrollTop|| 0;<br>先判断scroll距离顶部的值。你想要三页,你大概的算一下三页的高度。<br>if(s //假如3000是你三页的高,那么小于3000的就让它继续加载内容<br>}else{<br> //如果等于或者大于了,那么就在这里show出你的分页。<br>}<br><br>//根据你的实际情况去修改,思路你懂了吗 <div class="clear"> </div>

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

ToretrievedatafromaPHPsession,startthesessionwithsession_start()andaccessvariablesinthe$_SESSIONarray.Forexample:1)Startthesession:session_start().2)Retrievedata:$username=$_SESSION['username'];echo"Welcome,".$username;.Sessionsareserver-si

The steps to build an efficient shopping cart system using sessions include: 1) Understand the definition and function of the session. The session is a server-side storage mechanism used to maintain user status across requests; 2) Implement basic session management, such as adding products to the shopping cart; 3) Expand to advanced usage, supporting product quantity management and deletion; 4) Optimize performance and security, by persisting session data and using secure session identifiers.

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
